public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] libstdc++: use a link test to test for -Wl,-z,relro
       [not found] ` <55847215-ec15-0bfe-4d73-3dffb5c8c801@gmail.com>
@ 2020-09-16 12:11   ` JonY
  2020-09-22  8:50     ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: JonY @ 2020-09-16 12:11 UTC (permalink / raw)
  To: Gcc Patch List; +Cc: libstdc++


[-- Attachment #1.1: Type: text/plain, Size: 483 bytes --]

On 9/13/20 3:37 PM, JonY wrote:
> On 9/10/20 2:23 PM, JonY wrote:
>> Do a link test instead of just a grep. The linker can
>> support multiple targets, but not all targets can use it.
>>
>> Cygwin/MinGW ld can support ELF but the PE format for Windows itself
>> does not support such a feature. Attached patch OK?
>>
>> I'm not confident with regenerating configure due to some unrelated
>> changes added, can someone else help with that?
>>
> 
> Ping?
> 

Ping 2?


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++: use a link test to test for -Wl,-z,relro
  2020-09-16 12:11   ` [PATCH] libstdc++: use a link test to test for -Wl,-z,relro JonY
@ 2020-09-22  8:50     ` Jonathan Wakely
  2020-09-22  9:40       ` JonY
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2020-09-22  8:50 UTC (permalink / raw)
  To: JonY; +Cc: Gcc Patch List, libstdc++

On 16/09/20 12:11 +0000, JonY via Libstdc++ wrote:
>On 9/13/20 3:37 PM, JonY wrote:
>> On 9/10/20 2:23 PM, JonY wrote:
>>> Do a link test instead of just a grep. The linker can
>>> support multiple targets, but not all targets can use it.
>>>
>>> Cygwin/MinGW ld can support ELF but the PE format for Windows itself
>>> does not support such a feature. Attached patch OK?
>>>
>>> I'm not confident with regenerating configure due to some unrelated
>>> changes added, can someone else help with that?
>>>
>>
>> Ping?
>>
>
>Ping 2?
>

I don't see a patch, or any previous email to the libstdc++ list.

Please resend with the patch, CCing libstdc++@

Thanks.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++: use a link test to test for -Wl,-z,relro
  2020-09-22  8:50     ` Jonathan Wakely
@ 2020-09-22  9:40       ` JonY
  2020-09-22  9:58         ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: JonY @ 2020-09-22  9:40 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Gcc Patch List, libstdc++


[-- Attachment #1.1.1: Type: text/plain, Size: 487 bytes --]

On 9/22/20 8:50 AM, Jonathan Wakely wrote:
> 
> I don't see a patch, or any previous email to the libstdc++ list.
> 
> Please resend with the patch, CCing libstdc++@
> 
> Thanks.
> 
> 
> 

Resent for the record. I've been told it might not be appropriate
because some targets cannot link yet and therefore will fail incorrectly.

Currently, the linker support is misdetected since binutils can support
multiple targets. MinGW/Cygwin PE formats don't support such a flag.

[-- Attachment #1.1.2: 1b20e03e7468760828bfc70fc5e811b5b3738adf.txt --]
[-- Type: text/plain, Size: 1226 bytes --]

From: Jonathan Yong <10walls@gmail.com>
Date: Sun, 22 Mar 2020 01:59:37 +0000 (+0800)
Subject: libstdc++: use a link test to test for -Wl,-z,relro
X-Git-Url: https://repo.or.cz/gcc/cygwin-gcc.git/commitdiff_plain/1b20e03e7468760828bfc70fc5e811b5b3738adf

libstdc++: use a link test to test for -Wl,-z,relro

Do a link test instead of just a grep. The linker can
support multiple targets, but not all targets can use it.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
---

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index bc7d137dc74..209aa3a91f3 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -274,7 +274,16 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
   ac_ld_relro=no
   if test x"$with_gnu_ld" = x"yes"; then
     AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
-    cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
+    ac_save_ldflags="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -Wl,-z,relro"
+    AC_LINK_IFELSE([
+      AC_LANG_SOURCE(
+        [[int main() { return 0; }]]
+      )],
+      [cxx_z_relo="1"],
+      [cxx_z_relo=""])
+   LDFLAGS="$ac_save_ldflags"
+
     if test -n "$cxx_z_relo"; then
       OPT_LDFLAGS="-Wl,-z,relro"
       ac_ld_relro=yes

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libstdc++: use a link test to test for -Wl,-z,relro
  2020-09-22  9:40       ` JonY
@ 2020-09-22  9:58         ` Jonathan Wakely
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2020-09-22  9:58 UTC (permalink / raw)
  To: JonY; +Cc: libstdc++, Gcc Patch List

On 22/09/20 09:40 +0000, JonY via Libstdc++ wrote:
>On 9/22/20 8:50 AM, Jonathan Wakely wrote:
>>
>> I don't see a patch, or any previous email to the libstdc++ list.
>>
>> Please resend with the patch, CCing libstdc++@
>>
>> Thanks.
>>
>>
>>
>
>Resent for the record.

Thanks.

>I've been told it might not be appropriate
>because some targets cannot link yet and therefore will fail incorrectly.


We only use the GLIBCXX_CHECK_LINKER_FEATURES macro for native builds,
or for specific cross targets.  And we already do AC_TRY_LINK just
before the relro check, so I think it's probably OK. But I admit to
not fully understanding this.


>Currently, the linker support is misdetected since binutils can support
>multiple targets. MinGW/Cygwin PE formats don't support such a flag.

>From: Jonathan Yong <10walls@gmail.com>
>Date: Sun, 22 Mar 2020 01:59:37 +0000 (+0800)
>Subject: libstdc++: use a link test to test for -Wl,-z,relro
>X-Git-Url: https://repo.or.cz/gcc/cygwin-gcc.git/commitdiff_plain/1b20e03e7468760828bfc70fc5e811b5b3738adf
>
>libstdc++: use a link test to test for -Wl,-z,relro
>
>Do a link test instead of just a grep. The linker can
>support multiple targets, but not all targets can use it.
>
>Signed-off-by: Jonathan Yong <10walls@gmail.com>
>---
>
>diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
>index bc7d137dc74..209aa3a91f3 100644
>--- a/libstdc++-v3/acinclude.m4
>+++ b/libstdc++-v3/acinclude.m4
>@@ -274,7 +274,16 @@ AC_DEFUN([GLIBCXX_CHECK_LINKER_FEATURES], [
>   ac_ld_relro=no
>   if test x"$with_gnu_ld" = x"yes"; then
>     AC_MSG_CHECKING([for ld that supports -Wl,-z,relro])
>-    cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
>+    ac_save_ldflags="$LDFLAGS"
>+    LDFLAGS="$LDFLAGS -Wl,-z,relro"
>+    AC_LINK_IFELSE([
>+      AC_LANG_SOURCE(
>+        [[int main() { return 0; }]]
>+      )],
>+      [cxx_z_relo="1"],
>+      [cxx_z_relo=""])
>+   LDFLAGS="$ac_save_ldflags"
>+
>     if test -n "$cxx_z_relo"; then
>       OPT_LDFLAGS="-Wl,-z,relro"
>       ac_ld_relro=yes





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-22  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <d6d57a52-6cc5-efe2-af8e-616f924684e8@gmail.com>
     [not found] ` <55847215-ec15-0bfe-4d73-3dffb5c8c801@gmail.com>
2020-09-16 12:11   ` [PATCH] libstdc++: use a link test to test for -Wl,-z,relro JonY
2020-09-22  8:50     ` Jonathan Wakely
2020-09-22  9:40       ` JonY
2020-09-22  9:58         ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).