Change fno-unit-at-a-time to fno-toplevel-reorder

Message ID 20220416183628.3522663-1-maskray@google.com
State Superseded
Headers
Series Change fno-unit-at-a-time to fno-toplevel-reorder |

Checks

Context Check Description
dj/TryBot-32bit fail Patch caused testsuite regressions
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Fangrui Song April 16, 2022, 6:36 p.m. UTC
  -fno-toplevel-reorder is a rough replacement for the legacy option
-fno-unit-at-a-time
(https://sourceware.org/pipermail/gcc-patches/2006-January/186801.html).
glibc currently requires GCC>=6.2 which assuredly has
-fno-toplevel-reorder -fno-section-anchors. Clang will use the else
branch as it does not implement -fno-toplevel-reorder.
---
 config.make.in        | 2 +-
 configure             | 6 +++---
 configure.ac          | 6 +++---
 stdio-common/Makefile | 4 ++--
 4 files changed, 9 insertions(+), 9 deletions(-)
  

Comments

Fangrui Song May 1, 2022, 7:10 a.m. UTC | #1
On Sat, Apr 16, 2022 at 11:36 AM Fangrui Song <maskray@google.com> wrote:
>
> -fno-toplevel-reorder is a rough replacement for the legacy option
> -fno-unit-at-a-time
> (https://sourceware.org/pipermail/gcc-patches/2006-January/186801.html).
> glibc currently requires GCC>=6.2 which assuredly has
> -fno-toplevel-reorder -fno-section-anchors. Clang will use the else
> branch as it does not implement -fno-toplevel-reorder.
> ---
>  config.make.in        | 2 +-
>  configure             | 6 +++---
>  configure.ac          | 6 +++---
>  stdio-common/Makefile | 4 ++--
>  4 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/config.make.in b/config.make.in
> index bf728c71c0..65e1f46da4 100644
> --- a/config.make.in
> +++ b/config.make.in
> @@ -68,7 +68,7 @@ have-selinux = @have_selinux@
>  have-libaudit = @have_libaudit@
>  have-libcap = @have_libcap@
>  have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
> -fno-unit-at-a-time = @fno_unit_at_a_time@
> +fno-toplevel-reorder = @fno_toplevel_reorder@
>  bind-now = @bindnow@
>  have-hash-style = @libc_cv_hashstyle@
>  use-default-link = @use_default_link@
> diff --git a/configure b/configure
> index d2f413d05d..4c7b159b13 100755
> --- a/configure
> +++ b/configure
> @@ -620,7 +620,7 @@ libc_cv_cc_loop_to_function
>  libc_cv_cc_submachine
>  libc_cv_cc_nofma
>  libc_cv_mtls_dialect_gnu2
> -fno_unit_at_a_time
> +fno_toplevel_reorder
>  libc_cv_has_glob_dat
>  libc_cv_hashstyle
>  libc_cv_fpie
> @@ -6305,9 +6305,9 @@ fi
>  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
>  $as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
>  if test $libc_cv_fno_toplevel_reorder = yes; then
> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>  else
> -  fno_unit_at_a_time=-fno-unit-at-a-time
> +  fno_toplevel_reorder=
>  fi
>
>
> diff --git a/configure.ac b/configure.ac
> index b6a747dece..bdff5981c1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1460,11 +1460,11 @@ else
>  fi
>  rm -f conftest*])
>  if test $libc_cv_fno_toplevel_reorder = yes; then
> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>  else
> -  fno_unit_at_a_time=-fno-unit-at-a-time
> +  fno_toplevel_reorder=
>  fi
> -AC_SUBST(fno_unit_at_a_time)
> +AC_SUBST(fno_toplevel_reorder)
>
>  AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
>  [dnl
> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
> index 435cd8904f..6de2dd84ce 100644
> --- a/stdio-common/Makefile
> +++ b/stdio-common/Makefile
> @@ -333,8 +333,8 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
>  CFLAGS-isoc99_vscanf.c += -fexceptions
>  CFLAGS-isoc99_fscanf.c += -fexceptions
>  CFLAGS-isoc99_scanf.c += -fexceptions
> -CFLAGS-errlist.c += $(fno-unit-at-a-time)
> -CFLAGS-siglist.c += $(fno-unit-at-a-time)
> +CFLAGS-errlist.c += $(fno-toplevel-reorder)
> +CFLAGS-siglist.c += $(fno-toplevel-reorder)
>
>  # scanf14a.c and scanf16a.c test a deprecated extension which is no
>  # longer visible under most conformance levels; see the source files
> --
> 2.36.0.rc0.470.gd361397f0d-goog
>

Ping
  
Adhemerval Zanella Netto May 4, 2022, 6:34 p.m. UTC | #2
On 16/04/2022 15:36, Fangrui Song wrote:
> -fno-toplevel-reorder is a rough replacement for the legacy option
> -fno-unit-at-a-time
> (https://sourceware.org/pipermail/gcc-patches/2006-January/186801.html).
> glibc currently requires GCC>=6.2 which assuredly has
> -fno-toplevel-reorder -fno-section-anchors. Clang will use the else
> branch as it does not implement -fno-toplevel-reorder.

I don't see much improvement here, it just trades one option by another.
Maybe a better approach would to reorganize the code to avoid requiring
special compiler options.

I did it for the gcc clang work [1], so check-abi is clean.

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/fno-unit-at-fime-removal

> ---
>  config.make.in        | 2 +-
>  configure             | 6 +++---
>  configure.ac          | 6 +++---
>  stdio-common/Makefile | 4 ++--
>  4 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/config.make.in b/config.make.in
> index bf728c71c0..65e1f46da4 100644
> --- a/config.make.in
> +++ b/config.make.in
> @@ -68,7 +68,7 @@ have-selinux = @have_selinux@
>  have-libaudit = @have_libaudit@
>  have-libcap = @have_libcap@
>  have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
> -fno-unit-at-a-time = @fno_unit_at_a_time@
> +fno-toplevel-reorder = @fno_toplevel_reorder@
>  bind-now = @bindnow@
>  have-hash-style = @libc_cv_hashstyle@
>  use-default-link = @use_default_link@
> diff --git a/configure b/configure
> index d2f413d05d..4c7b159b13 100755
> --- a/configure
> +++ b/configure
> @@ -620,7 +620,7 @@ libc_cv_cc_loop_to_function
>  libc_cv_cc_submachine
>  libc_cv_cc_nofma
>  libc_cv_mtls_dialect_gnu2
> -fno_unit_at_a_time
> +fno_toplevel_reorder
>  libc_cv_has_glob_dat
>  libc_cv_hashstyle
>  libc_cv_fpie
> @@ -6305,9 +6305,9 @@ fi
>  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
>  $as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
>  if test $libc_cv_fno_toplevel_reorder = yes; then
> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>  else
> -  fno_unit_at_a_time=-fno-unit-at-a-time
> +  fno_toplevel_reorder=
>  fi
>  
>  
> diff --git a/configure.ac b/configure.ac
> index b6a747dece..bdff5981c1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1460,11 +1460,11 @@ else
>  fi
>  rm -f conftest*])
>  if test $libc_cv_fno_toplevel_reorder = yes; then
> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>  else
> -  fno_unit_at_a_time=-fno-unit-at-a-time
> +  fno_toplevel_reorder=
>  fi
> -AC_SUBST(fno_unit_at_a_time)
> +AC_SUBST(fno_toplevel_reorder)
>  
>  AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
>  [dnl
> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
> index 435cd8904f..6de2dd84ce 100644
> --- a/stdio-common/Makefile
> +++ b/stdio-common/Makefile
> @@ -333,8 +333,8 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
>  CFLAGS-isoc99_vscanf.c += -fexceptions
>  CFLAGS-isoc99_fscanf.c += -fexceptions
>  CFLAGS-isoc99_scanf.c += -fexceptions
> -CFLAGS-errlist.c += $(fno-unit-at-a-time)
> -CFLAGS-siglist.c += $(fno-unit-at-a-time)
> +CFLAGS-errlist.c += $(fno-toplevel-reorder)
> +CFLAGS-siglist.c += $(fno-toplevel-reorder)
>  
>  # scanf14a.c and scanf16a.c test a deprecated extension which is no
>  # longer visible under most conformance levels; see the source files
  
Fangrui Song May 11, 2022, 6:57 p.m. UTC | #3
On 2022-05-04, Adhemerval Zanella wrote:
>
>
>On 16/04/2022 15:36, Fangrui Song wrote:
>> -fno-toplevel-reorder is a rough replacement for the legacy option
>> -fno-unit-at-a-time
>> (https://sourceware.org/pipermail/gcc-patches/2006-January/186801.html).
>> glibc currently requires GCC>=6.2 which assuredly has
>> -fno-toplevel-reorder -fno-section-anchors. Clang will use the else
>> branch as it does not implement -fno-toplevel-reorder.
>
>I don't see much improvement here, it just trades one option by another.
>Maybe a better approach would to reorganize the code to avoid requiring
>special compiler options.

The patch ensures the legacy -fno-unit-at-a-time option is no longer used.
With the GNU as patch https://sourceware.org/pipermail/binutils/2022-April/120311.html (gas: copy st_size only if unset)
and the LLVM integrated assembler patch https://reviews.llvm.org/D123283 ([MC][ELF] Improve st_size propagation rule),
the glibc code as is is robust enough.

Removing -fno-toplevel-reorder needs the unreleased binutils 2.39, so fno-toplevel-reorder can be kept for now.

>I did it for the gcc clang work [1], so check-abi is clean.
>
>[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/azanella/fno-unit-at-fime-removal

This will be fine, too.

>> ---
>>  config.make.in        | 2 +-
>>  configure             | 6 +++---
>>  configure.ac          | 6 +++---
>>  stdio-common/Makefile | 4 ++--
>>  4 files changed, 9 insertions(+), 9 deletions(-)
>>
>> diff --git a/config.make.in b/config.make.in
>> index bf728c71c0..65e1f46da4 100644
>> --- a/config.make.in
>> +++ b/config.make.in
>> @@ -68,7 +68,7 @@ have-selinux = @have_selinux@
>>  have-libaudit = @have_libaudit@
>>  have-libcap = @have_libcap@
>>  have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
>> -fno-unit-at-a-time = @fno_unit_at_a_time@
>> +fno-toplevel-reorder = @fno_toplevel_reorder@
>>  bind-now = @bindnow@
>>  have-hash-style = @libc_cv_hashstyle@
>>  use-default-link = @use_default_link@
>> diff --git a/configure b/configure
>> index d2f413d05d..4c7b159b13 100755
>> --- a/configure
>> +++ b/configure
>> @@ -620,7 +620,7 @@ libc_cv_cc_loop_to_function
>>  libc_cv_cc_submachine
>>  libc_cv_cc_nofma
>>  libc_cv_mtls_dialect_gnu2
>> -fno_unit_at_a_time
>> +fno_toplevel_reorder
>>  libc_cv_has_glob_dat
>>  libc_cv_hashstyle
>>  libc_cv_fpie
>> @@ -6305,9 +6305,9 @@ fi
>>  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
>>  $as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
>>  if test $libc_cv_fno_toplevel_reorder = yes; then
>> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
>> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>>  else
>> -  fno_unit_at_a_time=-fno-unit-at-a-time
>> +  fno_toplevel_reorder=
>>  fi
>>
>>
>> diff --git a/configure.ac b/configure.ac
>> index b6a747dece..bdff5981c1 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1460,11 +1460,11 @@ else
>>  fi
>>  rm -f conftest*])
>>  if test $libc_cv_fno_toplevel_reorder = yes; then
>> -  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
>> +  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
>>  else
>> -  fno_unit_at_a_time=-fno-unit-at-a-time
>> +  fno_toplevel_reorder=
>>  fi
>> -AC_SUBST(fno_unit_at_a_time)
>> +AC_SUBST(fno_toplevel_reorder)
>>
>>  AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
>>  [dnl
>> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
>> index 435cd8904f..6de2dd84ce 100644
>> --- a/stdio-common/Makefile
>> +++ b/stdio-common/Makefile
>> @@ -333,8 +333,8 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
>>  CFLAGS-isoc99_vscanf.c += -fexceptions
>>  CFLAGS-isoc99_fscanf.c += -fexceptions
>>  CFLAGS-isoc99_scanf.c += -fexceptions
>> -CFLAGS-errlist.c += $(fno-unit-at-a-time)
>> -CFLAGS-siglist.c += $(fno-unit-at-a-time)
>> +CFLAGS-errlist.c += $(fno-toplevel-reorder)
>> +CFLAGS-siglist.c += $(fno-toplevel-reorder)
>>
>>  # scanf14a.c and scanf16a.c test a deprecated extension which is no
>>  # longer visible under most conformance levels; see the source files
  

Patch

diff --git a/config.make.in b/config.make.in
index bf728c71c0..65e1f46da4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -68,7 +68,7 @@  have-selinux = @have_selinux@
 have-libaudit = @have_libaudit@
 have-libcap = @have_libcap@
 have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
-fno-unit-at-a-time = @fno_unit_at_a_time@
+fno-toplevel-reorder = @fno_toplevel_reorder@
 bind-now = @bindnow@
 have-hash-style = @libc_cv_hashstyle@
 use-default-link = @use_default_link@
diff --git a/configure b/configure
index d2f413d05d..4c7b159b13 100755
--- a/configure
+++ b/configure
@@ -620,7 +620,7 @@  libc_cv_cc_loop_to_function
 libc_cv_cc_submachine
 libc_cv_cc_nofma
 libc_cv_mtls_dialect_gnu2
-fno_unit_at_a_time
+fno_toplevel_reorder
 libc_cv_has_glob_dat
 libc_cv_hashstyle
 libc_cv_fpie
@@ -6305,9 +6305,9 @@  fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
 $as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
 if test $libc_cv_fno_toplevel_reorder = yes; then
-  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
+  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
 else
-  fno_unit_at_a_time=-fno-unit-at-a-time
+  fno_toplevel_reorder=
 fi
 
 
diff --git a/configure.ac b/configure.ac
index b6a747dece..bdff5981c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1460,11 +1460,11 @@  else
 fi
 rm -f conftest*])
 if test $libc_cv_fno_toplevel_reorder = yes; then
-  fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
+  fno_toplevel_reorder="-fno-toplevel-reorder -fno-section-anchors"
 else
-  fno_unit_at_a_time=-fno-unit-at-a-time
+  fno_toplevel_reorder=
 fi
-AC_SUBST(fno_unit_at_a_time)
+AC_SUBST(fno_toplevel_reorder)
 
 AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
 [dnl
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 435cd8904f..6de2dd84ce 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -333,8 +333,8 @@  CFLAGS-isoc99_vfscanf.c += -fexceptions
 CFLAGS-isoc99_vscanf.c += -fexceptions
 CFLAGS-isoc99_fscanf.c += -fexceptions
 CFLAGS-isoc99_scanf.c += -fexceptions
-CFLAGS-errlist.c += $(fno-unit-at-a-time)
-CFLAGS-siglist.c += $(fno-unit-at-a-time)
+CFLAGS-errlist.c += $(fno-toplevel-reorder)
+CFLAGS-siglist.c += $(fno-toplevel-reorder)
 
 # scanf14a.c and scanf16a.c test a deprecated extension which is no
 # longer visible under most conformance levels; see the source files