From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 6636C3858D35; Mon, 22 Apr 2024 13:11:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6636C3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713791460; bh=re3HQGZ6kDuANZz1BWHm21FJbibST71iaX2XcmDgzeU=; h=From:To:Subject:Date:From; b=LvCt+EScoWN3rkb2aizbxBvIMIFDdmtlgE8E5gOs6d2fDVM4/Q5ItosQeMkmlSVZc g/wZooOiCYDYXIewkcH0z5c48pSpBmOJOAtG03IhG5vagk8KIqfrTtiWbbQe/BYri9 rd39H306E6MtBOiWfCeIgESgC/dOn4xhCB3Qg3ts= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-11336] testsuite: Fix weak_undefined handling on Darwin X-Act-Checkin: gcc X-Git-Author: Rainer Orth X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: ce169d2712296b193ecb94768fee1477bb0d0ed0 X-Git-Newrev: d79d1073c444ceb85b3cd2f55be7b4dfe598d287 Message-Id: <20240422131100.6636C3858D35@sourceware.org> Date: Mon, 22 Apr 2024 13:11:00 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d79d1073c444ceb85b3cd2f55be7b4dfe598d287 commit r11-11336-gd79d1073c444ceb85b3cd2f55be7b4dfe598d287 Author: Rainer Orth Date: Tue Mar 28 10:40:05 2023 +0200 testsuite: Fix weak_undefined handling on Darwin The patch that introduced the weak_undefined effective-target keyword and corresponding dg-add-options support commit 378ec7b87a5265dbe2d489c245fac98ef37fa638 Author: Alexandre Oliva Date: Thu Mar 23 00:45:05 2023 -0300 [testsuite] test for weak_undefined support and add options badly broke the affected tests on macOS like so: ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined " ERROR: gcc.dg/addr_equal-1.c: unknown dg option: 89 for " dg-add-options 5 weak_undefined " add_options_for_weak_undefined tries to call an non-existant proc "89". Even after fixing this by escaping the brackets, two tests still failed to link since they lacked the corresponding calls do dg-add-options weak_undefined. Tested on x86_64-apple-darwin20.6.0 and i386-pc-solaris2.11. 2023-03-27 Rainer Orth gcc/testsuite: * lib/target-supports.exp (add_options_for_weak_undefined): Escape brackets. * gcc.dg/visibility-22.c: Add weak_undefined options. (cherry picked from commit 8443f42f05f9026dadad1236b9e44ec294c70337) Diff: --- gcc/testsuite/gcc.dg/visibility-22.c | 1 + gcc/testsuite/lib/target-supports.exp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/gcc/testsuite/gcc.dg/visibility-22.c b/gcc/testsuite/gcc.dg/visibility-22.c index e2b78d1c7fd..9123b350b2e 100644 --- a/gcc/testsuite/gcc.dg/visibility-22.c +++ b/gcc/testsuite/gcc.dg/visibility-22.c @@ -3,6 +3,7 @@ /* { dg-require-visibility "" } */ /* { dg-require-effective-target weak_undefined } */ /* { dg-options "-O2 -fPIC" { target fpic } } */ +/* { dg-add-options weak_undefined } */ extern void foo () __attribute__((weak,visibility("hidden"))); int diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index a09606e4497..63a5f5579be 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -348,6 +348,18 @@ proc check_weak_available { } { } } +# return options to add to enable weak undefined symbols. + +proc add_options_for_weak_undefined { flags } { + if { [istarget *-*-darwin*] } { + lappend flags "-Wl,-undefined,dynamic_lookup" + if { [istarget *-*-darwin\[89\]*] } { + lappend flags "-Wl,-flat_namespace" + } + } + return $flags +} + # return 1 if weak undefined symbols are supported. proc check_effective_target_weak_undefined { } {