Enable hidden visibility in libc.a compiled with PIE

Message ID 70d5fb41-afd6-d4de-7e60-2f010fbca690@redhat.com
State Committed
Headers

Commit Message

Florian Weimer Aug. 21, 2017, 3:52 p.m. UTC
  On 08/21/2017 05:48 PM, Florian Weimer wrote:
> On 08/08/2017 06:40 PM, H.J. Lu wrote:
>> -#if defined SHARED || defined LIBC_NONSHARED
>> +#if defined SHARED || defined LIBC_NONSHARED \
>> +  || (BUILD_PIE_DEFAULT && IS_IN (libc))
>>  # define attribute_hidden __attribute__ ((visibility ("hidden")))
>>  #else
>>  # define attribute_hidden
> 
> I think this broke “make subdirs=benchtests bench-build” because
> json-lib.c is erroneously compiled with -DMODULE_NAME=libc.

I think this fixes it.

Florian
  

Comments

H.J. Lu Aug. 21, 2017, 3:57 p.m. UTC | #1
On Mon, Aug 21, 2017 at 8:52 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/21/2017 05:48 PM, Florian Weimer wrote:
>> On 08/08/2017 06:40 PM, H.J. Lu wrote:
>>> -#if defined SHARED || defined LIBC_NONSHARED
>>> +#if defined SHARED || defined LIBC_NONSHARED \
>>> +  || (BUILD_PIE_DEFAULT && IS_IN (libc))
>>>  # define attribute_hidden __attribute__ ((visibility ("hidden")))
>>>  #else
>>>  # define attribute_hidden
>>
>> I think this broke “make subdirs=benchtests bench-build” because
>> json-lib.c is erroneously compiled with -DMODULE_NAME=libc.

Yes, this is

https://sourceware.org/bugzilla/show_bug.cgi?id=21864

> I think this fixes it.
>
> Florian

LGTM.  Please add "[BZ #21864]" in ChangeLog entry.

Thanks.
  

Patch

benchtests: Do not compile benchmark helper objects as libc modules

Otherwise, this will lead to link failures due to hidden symbol
references.

2017-08-21  Florian Weimer  <fweimer@redhat.com>

	Do not compile benchmark helper objects with -DMODULE_NAME=libc.
	* benchtests/Makefile (others-extras): Set to $(bench-extra-objs).
	Move before inclusion of ../Rules.

diff --git a/benchtests/Makefile b/benchtests/Makefile
index 37788e8c31..a0c3470398 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -93,6 +93,11 @@  $(objpfx)bench-malloc-thread: $(shared-thread-library)
 # affect their performance.
 .NOTPARALLEL:
 
+bench-extra-objs = json-lib.o
+
+extra-objs += $(bench-extra-objs)
+others-extras = $(bench-extra-objs)
+
 include ../Rules
 
 binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
@@ -125,10 +130,6 @@  cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c) \
 lib := nonlib
 include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
 
-bench-extra-objs = json-lib.o
-
-extra-objs += $(bench-extra-objs)
-
 bench-deps := bench-skeleton.c bench-timing.h Makefile
 
 run-bench = $(test-wrapper-env) \