[3/3] install: Replace scripts/output-format.sed with objdump -f [BZ #26559]

Message ID 20201228194855.510315-4-maskray@google.com
State Committed
Commit 87d583c6e8cd0e49f64da76636ebeec033298b4d
Headers
Series Make glibc build with LLD |

Commit Message

Fangrui Song Dec. 28, 2020, 7:48 p.m. UTC
  GNU ld and gold have supported --print-output-format since 2011. glibc
requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
assume the option is supported.

lld is by default a cross linker supporting multiple targets. It auto
detects the file format and does not need OUTPUT_FORMAT. It does not
support --print-output-format.

By parsing objdump -f, we can support all the three linkers.
---
 Makerules                                     | 13 ++-----
 .../strcoll-inputs/filelist#en_US.UTF-8       |  1 -
 config.make.in                                |  1 -
 configure                                     | 19 ----------
 configure.ac                                  | 11 ------
 scripts/output-format.sed                     | 35 -------------------
 6 files changed, 3 insertions(+), 77 deletions(-)
 delete mode 100644 scripts/output-format.sed
  

Comments

Adhemerval Zanella Netto Jan. 8, 2021, 7:38 p.m. UTC | #1
On 28/12/2020 16:48, Fangrui Song via Libc-alpha wrote:
> GNU ld and gold have supported --print-output-format since 2011. glibc
> requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
> assume the option is supported.
> 
> lld is by default a cross linker supporting multiple targets. It auto
> detects the file format and does not need OUTPUT_FORMAT. It does not
> support --print-output-format.
> 
> By parsing objdump -f, we can support all the three linkers.

LGTM and this change seems orthogonal to the other lld adjustments.
I have checked that at least with a build for a handful of supported
ABIs I see no difference with ld.bfd (with multiple versions).

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  Makerules                                     | 13 ++-----
>  .../strcoll-inputs/filelist#en_US.UTF-8       |  1 -
>  config.make.in                                |  1 -
>  configure                                     | 19 ----------
>  configure.ac                                  | 11 ------
>  scripts/output-format.sed                     | 35 -------------------
>  6 files changed, 3 insertions(+), 77 deletions(-)
>  delete mode 100644 scripts/output-format.sed
> 
> diff --git a/Makerules b/Makerules
> index ef0fe67d9a..146d1ab650 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -1065,20 +1065,13 @@ install: $(inst_slibdir)/libc.so$(libc.so-version)
>  # for the configuration we are building.  We put this statement into
>  # the linker scripts we install for -lc et al so that they will not be
>  # used by a link for a different format on a multi-architecture system.
> -$(common-objpfx)format.lds: $(..)scripts/output-format.sed \
> -			    $(common-objpfx)config.make \
> +$(common-objpfx)format.lds: $(common-objpfx)config.make \
>  			    $(common-objpfx)config.h $(..)Makerules
> -ifneq (unknown,$(output-format))
> -	echo > $@.new 'OUTPUT_FORMAT($(output-format))'
> -else
>  	$(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
>  		  $(LDFLAGS.so) $(LDFLAGS-lib.so) \
> -		  -x c /dev/null -o $@.so -Wl,--verbose -v 2>/dev/null \
> -	| sed -n -f $< > $@.new
> -	test -s $@.new
> +		  -x c /dev/null -o $@.so 2>/dev/null
> +	$(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
>  	rm -f $@.so
> -endif
> -	mv -f $@.new $@
>  common-generated += format.lds
>  
>  ifndef subdir

Ok.

> diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> index 2f4ef195bb..43eb9efb40 100644
> --- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> +++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
> @@ -9450,7 +9450,6 @@ move-if-change
>  check-execstack.awk
>  pylint
>  pylintrc
> -output-format.sed
>  merge-test-results.sh
>  update-copyrights
>  config-uname.sh

Ok.

> diff --git a/config.make.in b/config.make.in
> index 7ae27564fd..7f47f0caa4 100644
> --- a/config.make.in
> +++ b/config.make.in
> @@ -73,7 +73,6 @@ fno-unit-at-a-time = @fno_unit_at_a_time@
>  bind-now = @bindnow@
>  have-hash-style = @libc_cv_hashstyle@
>  use-default-link = @use_default_link@
> -output-format = @libc_cv_output_format@
>  have-cxx-thread_local = @libc_cv_cxx_thread_local@
>  have-loop-to-function = @libc_cv_cc_loop_to_function@
>  have-textrel_ifunc = @libc_cv_textrel_ifunc@

Ok.

> diff --git a/configure b/configure
> index 6dcd2270f8..4b0ab150cb 100755
> --- a/configure
> +++ b/configure
> @@ -623,7 +623,6 @@ libc_cv_cc_submachine
>  libc_cv_cc_nofma
>  libc_cv_mtls_dialect_gnu2
>  fno_unit_at_a_time
> -libc_cv_output_format
>  libc_cv_has_glob_dat
>  libc_cv_hashstyle
>  libc_cv_fpie
> @@ -6077,24 +6076,6 @@ fi
>  $as_echo "$libc_cv_has_glob_dat" >&6; }
>  
>  
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
> -$as_echo_n "checking linker output format... " >&6; }
> -if ${libc_cv_output_format+:} false; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  if libc_cv_output_format=`
> -${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&5`
> -then
> -  :
> -else
> -  libc_cv_output_format=
> -fi
> -test -n "$libc_cv_output_format" || libc_cv_output_format=unknown
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_output_format" >&5
> -$as_echo "$libc_cv_output_format" >&6; }
> -
> -
>  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
>  $as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
>  if ${libc_cv_fno_toplevel_reorder+:} false; then :
> diff --git a/configure.ac b/configure.ac
> index 1a2054cd1a..baf3a05ae7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -1432,17 +1432,6 @@ fi
>  rm -f conftest*])
>  AC_SUBST(libc_cv_has_glob_dat)
>  
> -AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
> -if libc_cv_output_format=`
> -${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
> -then
> -  :
> -else
> -  libc_cv_output_format=
> -fi
> -test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
> -AC_SUBST(libc_cv_output_format)
> -
>  AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
>  cat > conftest.c <<EOF
>  int foo;

Ok.

> diff --git a/scripts/output-format.sed b/scripts/output-format.sed
> deleted file mode 100644
> index 364f52059f..0000000000
> --- a/scripts/output-format.sed
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/ld.*[ 	]-E[BL]/b f
> -/collect.*[ 	]-E[BL]/b f
> -/OUTPUT_FORMAT[^)]*$/{N
> -s/\n[	 ]*/ /
> -}
> -t o
> -: o
> -s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
> -t q
> -s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
> -t s
> -s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
> -t q
> -d
> -: s
> -s/"//g
> -G
> -s/\n//
> -s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
> -s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
> -s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
> -/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
> -q
> -: q
> -s/"//g
> -p
> -q
> -: f
> -s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
> -t h
> -s/^.*[ 	]-E\([BL]\)$/,\1/
> -t h
> -d
> -: h
> -h
> 

Ok.
  
Florian Weimer Jan. 12, 2021, 11:20 a.m. UTC | #2
* Adhemerval Zanella via Libc-alpha:

> On 28/12/2020 16:48, Fangrui Song via Libc-alpha wrote:
>> GNU ld and gold have supported --print-output-format since 2011. glibc
>> requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
>> assume the option is supported.
>> 
>> lld is by default a cross linker supporting multiple targets. It auto
>> detects the file format and does not need OUTPUT_FORMAT. It does not
>> support --print-output-format.
>> 
>> By parsing objdump -f, we can support all the three linkers.
>
> LGTM and this change seems orthogonal to the other lld adjustments.
> I have checked that at least with a build for a handful of supported
> ABIs I see no difference with ld.bfd (with multiple versions).

I see a cross-build failure during the initial static link bootstrap on
aarch64-linux-gnu during “make install”:

make[2]: Entering directory '/home/bmg/src/glibc'
aarch64-glibc-linux-gnu-gcc   -shared  -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1 \
          -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both  \
          -x c /dev/null -o /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds.so
/home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
/home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
make[2]: *** [Makerules:1070: /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds] Error 1

This affects other targets as well.

I guess using

  $(CC) -nostdlib -nostartfiles -shared -x assembler /dev/null

should work on most targets here.

Thanks,
Florian
  
Andreas Schwab Jan. 12, 2021, 11:32 a.m. UTC | #3
gcc   -shared -Wl,-z,force-bti -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1 \
          -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,now -Wl,--fatal-warnings \
          -x c /dev/null -o /home/abuild/rpmbuild/BUILD/glibc-2.32.9000.527.g87d583c6e8/cc-base/format.lds.so 2>/dev/null
make[1]: *** [Makerules:1070: /home/abuild/rpmbuild/BUILD/glibc-2.32.9000.527.g87d583c6e8/cc-base/format.lds] Error 1

Andreas.
  
Florian Weimer Jan. 12, 2021, 11:58 a.m. UTC | #4
* Andreas Schwab:

> gcc   -shared -Wl,-z,force-bti -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1 \
>           -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,now -Wl,--fatal-warnings \
>           -x c /dev/null -o /home/abuild/rpmbuild/BUILD/glibc-2.32.9000.527.g87d583c6e8/cc-base/format.lds.so 2>/dev/null
> make[1]: *** [Makerules:1070: /home/abuild/rpmbuild/BUILD/glibc-2.32.9000.527.g87d583c6e8/cc-base/format.lds] Error 1

<https://sourceware.org/pipermail/libc-alpha/2021-January/121535.html>

I'm testing the proposed fix.  So far it's looking good.

Thanks,
Florian
  
Adhemerval Zanella Netto Jan. 12, 2021, noon UTC | #5
On 12/01/2021 08:20, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> On 28/12/2020 16:48, Fangrui Song via Libc-alpha wrote:
>>> GNU ld and gold have supported --print-output-format since 2011. glibc
>>> requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
>>> assume the option is supported.
>>>
>>> lld is by default a cross linker supporting multiple targets. It auto
>>> detects the file format and does not need OUTPUT_FORMAT. It does not
>>> support --print-output-format.
>>>
>>> By parsing objdump -f, we can support all the three linkers.
>>
>> LGTM and this change seems orthogonal to the other lld adjustments.
>> I have checked that at least with a build for a handful of supported
>> ABIs I see no difference with ld.bfd (with multiple versions).
> 
> I see a cross-build failure during the initial static link bootstrap on
> aarch64-linux-gnu during “make install”:
> 
> make[2]: Entering directory '/home/bmg/src/glibc'
> aarch64-glibc-linux-gnu-gcc   -shared  -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1 \
>           -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both  \
>           -x c /dev/null -o /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds.so
> /home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
> /home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
> collect2: error: ld returned 1 exit status
> make[2]: *** [Makerules:1070: /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds] Error 1
> 
> This affects other targets as well.
> 
> I guess using
> 
>   $(CC) -nostdlib -nostartfiles -shared -x assembler /dev/null
> 
> should work on most targets here.

I haven't see it when a stage2 gcc, make install works as intended.  However I
did see it now with a stage1 gcc with build-many-glibcs.py.

The -nostdlib -nostartfiles seems to fix it indeed, I am checking with a
bootstrap using build-many-glibcs.py.
  
Fangrui Song Jan. 12, 2021, 5:46 p.m. UTC | #6
On Tue, Jan 12, 2021 at 4:00 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 12/01/2021 08:20, Florian Weimer wrote:
> > * Adhemerval Zanella via Libc-alpha:
> >
> >> On 28/12/2020 16:48, Fangrui Song via Libc-alpha wrote:
> >>> GNU ld and gold have supported --print-output-format since 2011. glibc
> >>> requires binutils>=2.25 (2015), so if LD is GNU ld or gold, we can
> >>> assume the option is supported.
> >>>
> >>> lld is by default a cross linker supporting multiple targets. It auto
> >>> detects the file format and does not need OUTPUT_FORMAT. It does not
> >>> support --print-output-format.
> >>>
> >>> By parsing objdump -f, we can support all the three linkers.
> >>
> >> LGTM and this change seems orthogonal to the other lld adjustments.
> >> I have checked that at least with a build for a handful of supported
> >> ABIs I see no difference with ld.bfd (with multiple versions).
> >
> > I see a cross-build failure during the initial static link bootstrap on
> > aarch64-linux-gnu during “make install”:
> >
> > make[2]: Entering directory '/home/bmg/src/glibc'
> > aarch64-glibc-linux-gnu-gcc   -shared  -Wl,-dynamic-linker=/lib/ld-linux-aarch64.so.1 \
> >           -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both  \
> >           -x c /dev/null -o /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds.so
> > /home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crti.o: No such file or directory
> > /home/bmg/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/10.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: cannot find crtn.o: No such file or directory
> > collect2: error: ld returned 1 exit status
> > make[2]: *** [Makerules:1070: /home/bmg/build/compilers/aarch64-linux-gnu/glibc/aarch64-linux-gnu/format.lds] Error 1
> >
> > This affects other targets as well.
> >
> > I guess using
> >
> >   $(CC) -nostdlib -nostartfiles -shared -x assembler /dev/null
> >
> > should work on most targets here.
>
> I haven't see it when a stage2 gcc, make install works as intended.  However I
> did see it now with a stage1 gcc with build-many-glibcs.py.
>
> The -nostdlib -nostartfiles seems to fix it indeed, I am checking with a
> bootstrap using build-many-glibcs.py.

Thanks for the fix 0400f928335a5e04c788e1c831d8825d42612c49!
  

Patch

diff --git a/Makerules b/Makerules
index ef0fe67d9a..146d1ab650 100644
--- a/Makerules
+++ b/Makerules
@@ -1065,20 +1065,13 @@  install: $(inst_slibdir)/libc.so$(libc.so-version)
 # for the configuration we are building.  We put this statement into
 # the linker scripts we install for -lc et al so that they will not be
 # used by a link for a different format on a multi-architecture system.
-$(common-objpfx)format.lds: $(..)scripts/output-format.sed \
-			    $(common-objpfx)config.make \
+$(common-objpfx)format.lds: $(common-objpfx)config.make \
 			    $(common-objpfx)config.h $(..)Makerules
-ifneq (unknown,$(output-format))
-	echo > $@.new 'OUTPUT_FORMAT($(output-format))'
-else
 	$(LINK.o) -shared $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
 		  $(LDFLAGS.so) $(LDFLAGS-lib.so) \
-		  -x c /dev/null -o $@.so -Wl,--verbose -v 2>/dev/null \
-	| sed -n -f $< > $@.new
-	test -s $@.new
+		  -x c /dev/null -o $@.so 2>/dev/null
+	$(OBJDUMP) -f $@.so | sed -n 's/.*file format \(.*\)/OUTPUT_FORMAT(\1)/;T;p' > $@
 	rm -f $@.so
-endif
-	mv -f $@.new $@
 common-generated += format.lds
 
 ifndef subdir
diff --git a/benchtests/strcoll-inputs/filelist#en_US.UTF-8 b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
index 2f4ef195bb..43eb9efb40 100644
--- a/benchtests/strcoll-inputs/filelist#en_US.UTF-8
+++ b/benchtests/strcoll-inputs/filelist#en_US.UTF-8
@@ -9450,7 +9450,6 @@  move-if-change
 check-execstack.awk
 pylint
 pylintrc
-output-format.sed
 merge-test-results.sh
 update-copyrights
 config-uname.sh
diff --git a/config.make.in b/config.make.in
index 7ae27564fd..7f47f0caa4 100644
--- a/config.make.in
+++ b/config.make.in
@@ -73,7 +73,6 @@  fno-unit-at-a-time = @fno_unit_at_a_time@
 bind-now = @bindnow@
 have-hash-style = @libc_cv_hashstyle@
 use-default-link = @use_default_link@
-output-format = @libc_cv_output_format@
 have-cxx-thread_local = @libc_cv_cxx_thread_local@
 have-loop-to-function = @libc_cv_cc_loop_to_function@
 have-textrel_ifunc = @libc_cv_textrel_ifunc@
diff --git a/configure b/configure
index 6dcd2270f8..4b0ab150cb 100755
--- a/configure
+++ b/configure
@@ -623,7 +623,6 @@  libc_cv_cc_submachine
 libc_cv_cc_nofma
 libc_cv_mtls_dialect_gnu2
 fno_unit_at_a_time
-libc_cv_output_format
 libc_cv_has_glob_dat
 libc_cv_hashstyle
 libc_cv_fpie
@@ -6077,24 +6076,6 @@  fi
 $as_echo "$libc_cv_has_glob_dat" >&6; }
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5
-$as_echo_n "checking linker output format... " >&6; }
-if ${libc_cv_output_format+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if libc_cv_output_format=`
-${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&5`
-then
-  :
-else
-  libc_cv_output_format=
-fi
-test -n "$libc_cv_output_format" || libc_cv_output_format=unknown
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_output_format" >&5
-$as_echo "$libc_cv_output_format" >&6; }
-
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
 $as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
 if ${libc_cv_fno_toplevel_reorder+:} false; then :
diff --git a/configure.ac b/configure.ac
index 1a2054cd1a..baf3a05ae7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1432,17 +1432,6 @@  fi
 rm -f conftest*])
 AC_SUBST(libc_cv_has_glob_dat)
 
-AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl
-if libc_cv_output_format=`
-${CC-cc} -nostartfiles -nostdlib $no_ssp -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD`
-then
-  :
-else
-  libc_cv_output_format=
-fi
-test -n "$libc_cv_output_format" || libc_cv_output_format=unknown])
-AC_SUBST(libc_cv_output_format)
-
 AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
 cat > conftest.c <<EOF
 int foo;
diff --git a/scripts/output-format.sed b/scripts/output-format.sed
deleted file mode 100644
index 364f52059f..0000000000
--- a/scripts/output-format.sed
+++ /dev/null
@@ -1,35 +0,0 @@ 
-/ld.*[ 	]-E[BL]/b f
-/collect.*[ 	]-E[BL]/b f
-/OUTPUT_FORMAT[^)]*$/{N
-s/\n[	 ]*/ /
-}
-t o
-: o
-s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
-t q
-s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
-t s
-s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
-t q
-d
-: s
-s/"//g
-G
-s/\n//
-s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
-s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
-/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
-q
-: q
-s/"//g
-p
-q
-: f
-s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
-t h
-s/^.*[ 	]-E\([BL]\)$/,\1/
-t h
-d
-: h
-h