Install libm.a as linker script [BZ #20539]

Message ID CAMXFM3szvCP13C1P_Ed8NVV_FTt4Q8avz4uW-a=UbpWqMnF5aw@mail.gmail.com
State New, archived
Headers

Commit Message

Andrew Senkevich Oct. 20, 2016, 7:20 p.m. UTC
  Hi,

to avoid static link fail w/o passing additional -lmvec option (while
building with GCC 6.1 and above) this patch makes libm.a installed as
linker script.
Tested on x86_64.  Ok for trunk?

2016-10-20  Andrew Senkevich  <andrew.senkevich@intel.com>

        [BZ #20539]
        * Makerules (install-lib.a): filter out libm.a in case of libmvec build.
        * math/Makefile: added rules for libm.a installation as linker script.

 $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
@@ -142,6 +142,19 @@ $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
              'AS_NEEDED ( $(libdir)/libmvec_nonshared.a
$(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
        ) > $@.new
        mv -f $@.new $@
+
+install-others = $(inst_libdir)/libm.a
+$(inst_libdir)/libm.a: $(common-objpfx)format.lds \
+                      $(libm) \
+                      $(libmvec) \
+                      $(+force)
+       (echo '/* GNU ld script'; echo '*/';\
+        cat $<; \
+        echo 'GROUP ( $(libdir)/libm-$(lib-version).a ' \
+             'AS_NEEDED ( $(libdir)/libmvec.a) )' \
+       ) > $@.new
+       cp $(objpfx)libm.a $(libdir)/libm-$(lib-version).a
+       mv -f $@.new $@
 endif

 # Rules for the test suite.


--
WBR,
Andrew
  

Comments

H.J. Lu Oct. 24, 2016, 10:02 p.m. UTC | #1
On Thu, Oct 20, 2016 at 12:20 PM, Andrew Senkevich
<andrew.n.senkevich@gmail.com> wrote:
> Hi,
>
> to avoid static link fail w/o passing additional -lmvec option (while
> building with GCC 6.1 and above) this patch makes libm.a installed as
> linker script.
> Tested on x86_64.  Ok for trunk?

A couple issues.  Don't use cut/paste since it adds some newlines
and the patch won't apply.

> 2016-10-20  Andrew Senkevich  <andrew.senkevich@intel.com>
>
>         [BZ #20539]
>         * Makerules (install-lib.a): filter out libm.a in case of libmvec build.
>         * math/Makefile: added rules for libm.a installation as linker script.
>
> diff --git a/Makerules b/Makerules
> index e865782..290f927 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -1190,7 +1190,9 @@ $(addprefix $(inst_sbindir)/,$(install-sbin)): \
>         $(do-install-program)
>  endif
>  ifdef install-lib
> -install-lib.a := $(filter lib%.a,$(install-lib))
> +ifeq ($(build-mathvec),yes)
> +install-lib.a := $(filter-out libm.a,$(filter lib%.a,$(install-lib)))
> +endif

Should we use $(install-lib-ldscripts) instead of libm.a here?

>  install-lib-non.a := $(filter-out lib%.a,$(install-lib))
>  ifdef install-lib-non.a
>  $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
> diff --git a/math/Makefile b/math/Makefile
> index 2aa6a34..a96ef30 100644
> --- a/math/Makefile
> +++ b/math/Makefile
> @@ -128,8 +128,8 @@ generated += $(foreach s,.c .S,$(call
> type-foreach, $(calls:s_%=m_%$(s))))
>  routines = $(call type-foreach, $(calls))
>
>  ifeq ($(build-mathvec),yes)
> -# We need to install libm.so as linker script
> -# for more comfortable use of vector math library.
> +# We need to install libm.so and libm.a as linker scripts
> +# for transparent use of vector math library.
>  install-lib-ldscripts := libm.so
>  install_subdir: $(inst_libdir)/libm.so
>  $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
> @@ -142,6 +142,19 @@ $(inst_libdir)/libm.so: $(common-objpfx)format.lds \
>               'AS_NEEDED ( $(libdir)/libmvec_nonshared.a
> $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
>         ) > $@.new
>         mv -f $@.new $@
> +
> +install-others = $(inst_libdir)/libm.a
> +$(inst_libdir)/libm.a: $(common-objpfx)format.lds \
> +                      $(libm) \
> +                      $(libmvec) \
> +                      $(+force)
> +       (echo '/* GNU ld script'; echo '*/';\
> +        cat $<; \
> +        echo 'GROUP ( $(libdir)/libm-$(lib-version).a ' \
> +             'AS_NEEDED ( $(libdir)/libmvec.a) )' \
                  ^^^^^^^^^^^^^ Remove it.
> +       ) > $@.new
> +       cp $(objpfx)libm.a $(libdir)/libm-$(lib-version).a
                                        ^^^^^ It should be inst_libdir.
> +       mv -f $@.new $@
>  endif
>
>  # Rules for the test suite.
>

Do you need to update rules for building static math tests with
libmvec.a?
  
Andrew Senkevich Nov. 14, 2016, 7:15 p.m. UTC | #2
2016-10-25 1:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>> diff --git a/Makerules b/Makerules
>> index e865782..290f927 100644
>> --- a/Makerules
>> +++ b/Makerules
>> @@ -1190,7 +1190,9 @@ $(addprefix $(inst_sbindir)/,$(install-sbin)): \
>>         $(do-install-program)
>>  endif
>>  ifdef install-lib
>> -install-lib.a := $(filter lib%.a,$(install-lib))
>> +ifeq ($(build-mathvec),yes)
>> +install-lib.a := $(filter-out libm.a,$(filter lib%.a,$(install-lib)))
>> +endif
>
> Should we use $(install-lib-ldscripts) instead of libm.a here?

I had tried but haven't rich a success.

>>  # Rules for the test suite.
>>
>
> Do you need to update rules for building static math tests with
> libmvec.a?

I haven't added -lmvec explicitly for any static math test so I think no.

Attached corrected version.


--
WBR,
Andrew
  
H.J. Lu Nov. 14, 2016, 7:21 p.m. UTC | #3
On Mon, Nov 14, 2016 at 11:15 AM, Andrew Senkevich
<andrew.n.senkevich@gmail.com> wrote:
> 2016-10-25 1:02 GMT+03:00 H.J. Lu <hjl.tools@gmail.com>:
>>> diff --git a/Makerules b/Makerules
>>> index e865782..290f927 100644
>>> --- a/Makerules
>>> +++ b/Makerules
>>> @@ -1190,7 +1190,9 @@ $(addprefix $(inst_sbindir)/,$(install-sbin)): \
>>>         $(do-install-program)
>>>  endif
>>>  ifdef install-lib
>>> -install-lib.a := $(filter lib%.a,$(install-lib))
>>> +ifeq ($(build-mathvec),yes)
>>> +install-lib.a := $(filter-out libm.a,$(filter lib%.a,$(install-lib)))
>>> +endif
>>
>> Should we use $(install-lib-ldscripts) instead of libm.a here?
>
> I had tried but haven't rich a success.

Did you add libm.a to install-lib-ldscripts?

>>>  # Rules for the test suite.
>>>
>>
>> Do you need to update rules for building static math tests with
>> libmvec.a?
>
> I haven't added -lmvec explicitly for any static math test so I think no.

Static math test in glibc may fail if the same bug is triggered
with ether new GCC or new test.

> Attached corrected version.
>


echo 'GROUP ( $(inst_libdir)/libm-$(lib-version).a $(inst_libdir)/libmvec.a )' \
                         ^^^^^^^^^^^^   Please use libdir here.
  

Patch

diff --git a/Makerules b/Makerules
index e865782..290f927 100644
--- a/Makerules
+++ b/Makerules
@@ -1190,7 +1190,9 @@  $(addprefix $(inst_sbindir)/,$(install-sbin)): \
        $(do-install-program)
 endif
 ifdef install-lib
-install-lib.a := $(filter lib%.a,$(install-lib))
+ifeq ($(build-mathvec),yes)
+install-lib.a := $(filter-out libm.a,$(filter lib%.a,$(install-lib)))
+endif
 install-lib-non.a := $(filter-out lib%.a,$(install-lib))
 ifdef install-lib-non.a
 $(addprefix $(inst_libdir)/$(libprefix),$(install-lib-non.a)): \
diff --git a/math/Makefile b/math/Makefile
index 2aa6a34..a96ef30 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -128,8 +128,8 @@  generated += $(foreach s,.c .S,$(call
type-foreach, $(calls:s_%=m_%$(s))))
 routines = $(call type-foreach, $(calls))

 ifeq ($(build-mathvec),yes)
-# We need to install libm.so as linker script
-# for more comfortable use of vector math library.
+# We need to install libm.so and libm.a as linker scripts
+# for transparent use of vector math library.
 install-lib-ldscripts := libm.so
 install_subdir: $(inst_libdir)/libm.so