public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] testsuite: require libc sym for -shared
@ 2024-01-22 16:25 Alexandre Oliva
  0 siblings, 0 replies; only message in thread
From: Alexandre Oliva @ 2024-01-22 16:25 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:170d1d2528548a2e2fc1a708c547d371f39c2a36

commit 170d1d2528548a2e2fc1a708c547d371f39c2a36
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jan 22 13:24:19 2024 -0300

    testsuite: require libc sym for -shared
    
    Targets whose binutils support -shared, but that don't have a shared
    libc, and that can't add PDC (non-PIC) to shared libraries, may
    succeed at the effective target test for -shared, because it brings
    nothing from libc, but tests that rely on -shared and that use bits
    from libc, such as g++.dg/lto/pr108772, fail despite requiring the
    shared effective target.
    
    Extend the effective target test to bring malloc() from libc, that's
    likely to be present in libc and bring a substantial amount of code if
    no shared libc is available.
    
    
    for  gcc/testsuite/ChangeLog
    
            * lib/target-supports.exp (check_effective_target_shared):
            Check for a static-only libc.

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 73360cd3a0d..213dad355a6 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1391,10 +1391,16 @@ proc check_effective_target_aarch64_tlsle32 { } {
 proc check_effective_target_shared { } {
     # Note that M68K has a multilib that supports -fpic but not
     # -fPIC, so we need to check both.  We test with a program that
-    # requires GOT references.
+    # requires GOT references, and with a libc symbol that would
+    # bring in significant parts of a static-only libc.  Absent a
+    # shared libc, this would make -shared tests fail, so we don't
+    # want to enable the shared effective target then.
     return [check_no_compiler_messages shared executable {
+	#include <stdlib.h>
 	extern int foo (void); extern int bar;
-	int baz (void) { return foo () + bar; }
+	char *baz (void) {
+	    return foo () + (char*) malloc (bar);
+	}
     } "-shared -fpic"]
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-22 16:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-22 16:25 [gcc(refs/users/aoliva/heads/testme)] testsuite: require libc sym for -shared Alexandre Oliva

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).