public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>,
	Aditya Kamath1 <Aditya.Kamath1@ibm.com>,
	"tom@tromey.com" <tom@tromey.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	Sangamesh Mallayya <sangamesh.swamy@in.ibm.com>,
	"simon.marchi@efficios.com" <simon.marchi@efficios.com>
Subject: Re: [PATCH] Modify align-c/align-c++ test case for AIX
Date: Tue, 21 Mar 2023 11:05:14 +0000	[thread overview]
Message-ID: <bf1def86-d246-a124-d76a-fcbdabe5968e@palves.net> (raw)
In-Reply-To: <61289f79c8c08ebe15112711954e1b05d49c92be.camel@de.ibm.com>

On 2023-03-21 7:41 a.m., Ulrich Weigand via Gdb-patches wrote:
> Aditya Kamath1 <Aditya.Kamath1@ibm.com> wrote:
> 
>> So clearly, linker optimises out unused global variables. More about the
>> same can be read in the documentation
>> {https://www.ibm.com/docs/en/aix/7.1?topic=l-ld-command } 
> 
> I see the -Wl,-bnogc option there, this makes sense.
> 
> I'm not sure why "-lodm -lcfg" should be necessary as well, this
> doesn't really appear related to me.  Can you try without those?
> 
> 
>> So I was thinking if we can pass these to our site.exp file if the target is AIX:
>>
>> set CC_FOR_TARGET "/opt/freeware/bin/gcc"
>> set CXX_FOR_TARGET "/opt/freeware/bin/g++"
>> set CXXFLAGS_FOR_TARGET "-O0 -w -g -gdwarf -maix64"
>> set CFLAGS_FOR_TARGET "-O0 -w -g -gdwarf -maix64"
>>
>> with the options -Wl,-bnogc  -lodm -lcfg. 
>>
>> We also use -maix32 for testing in 32 bit mode as well. 
>>
>> I think this would be a better patch and in AIX we will not be seeing
>> so many failures as we see now instead of the initial proposed ifdef patch.
>> Only thing is we need to add this in a file which I am not aware of such
>> that if the target is AIX we need to add these flags in the site.exp
>> file so that while running test cases we get this file to pass these flags
>> during the compilation of them. 
> 
> If the -bnogc flag is always necessary with the AIX linker, this
> should be handled automatically by the test instead of via site.exp.
> 
> I'm assuming this is only needed with test files that use global
> variables unused in the source code, but used by the debugger.
> I think it would be best to explicitly add the flag to those tests
> where it is needed.

I'm wondering whether __attribute__((used)) on the global variable makes any
difference.  IIRC with LLVM it prevents link-time stripping on Mach-O and PE/COFF,
but I don't know about XCOFF + GCC.  (It doesn't on ELF, you
need 'retain' for that.)

Pedro Alves

> 
> For example, for the align-c tests, you can change the beginning
> of run_alignment_test in gdb.base/align.exp.tcl to something like:
> 
>     set flags {debug}
>     if { "$lang" == "c++" } {
>         lappend flags "additional_flags=-std=c++11"
>     }
>     if { [istarget *-*-aix*] } {
>         # Disable linker garbage collection to avoid optimizing
>         # out global variables unused in the test source code.
>         lappend flags "ldflags=-Wl,-bnogc"
>     }
>     standard_testfile $filename
>     if {[prepare_for_testing "failed to prepare" "$testfile" $srcfile $flags]} {
>         return -1
>     }
> 
> Bye,
> Ulrich
> 


  reply	other threads:[~2023-03-21 11:05 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10  8:57 Aditya Kamath1
2023-03-10 14:46 ` Tom Tromey
2023-03-13 13:04   ` Aditya Kamath1
2023-03-13 14:10     ` Ulrich Weigand
2023-03-15 11:52       ` Aditya Kamath1
2023-03-15 12:45         ` Tom Tromey
2023-03-16  7:01           ` Aditya Kamath1
2023-03-17 17:06             ` Ulrich Weigand
2023-03-17 22:03             ` Tom Tromey
2023-03-21  7:01               ` Aditya Kamath1
2023-03-21  7:41                 ` Ulrich Weigand
2023-03-21 11:05                   ` Pedro Alves [this message]
2023-03-21 14:17                   ` Tom Tromey
2023-03-21 14:26                     ` Ulrich Weigand
2023-03-29 11:28                       ` Aditya Kamath1
2023-03-29 13:36                         ` Pedro Alves
2023-03-31 12:29                           ` Aditya Kamath1
2023-04-04 13:24                             ` Aditya Kamath1
2023-04-05 16:33                             ` Pedro Alves
2023-04-06 13:15                               ` Aditya Kamath1
2023-04-06 16:18                                 ` Pedro Alves
  -- strict thread matches above, loose matches on Subject: below --
2023-03-10  8:56 Aditya Kamath1
2023-03-10 10:08 ` Aditya Kamath1

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf1def86-d246-a124-d76a-fcbdabe5968e@palves.net \
    --to=pedro@palves.net \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=Ulrich.Weigand@de.ibm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simon.marchi@efficios.com \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).