From: Matt Rice <ratmice@gmail.com>
To: Tom Tromey <tom@tromey.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/7] Make the gdb.objc tests compile
Date: Mon, 17 Nov 2025 10:09:19 +0000 [thread overview]
Message-ID: <CACTLOFpczLCBcEEeYeaNOWz-csaooGWDMJp=Lja3wE+mJ5bvnQ@mail.gmail.com> (raw)
In-Reply-To: <20251117012752.2657208-3-tom@tromey.com>
On Mon, Nov 17, 2025 at 1:33 AM Tom Tromey <tom@tromey.com> wrote:
>
> The gdb.objc tests haven't compiled in years. This patch fixes this,
> based on a comment in bug 31671.
>
> I don't know whether this approach works with the clang implementation
> of Objective-C. However, it does work with GCC, provided that
> gnustep-base is installed.
I guess at the time all this stuff broke I never felt that was an option
(and still feel it is terrible, yet better than the status quo)...
Since it is likely *most* people running the testsuite won't have gnustep-base
installed, nor all its shell script environment variables since it
tends to install
its header files in weird locations.
I don't see all those -I and -L flags though, so this seems likely it
depends upon
a certain installation/configuration of gnustep-base which installs
stuff in places
the compiler will pick them up (likely a distro's specific
configuration which isn't
the default to conform to distribution specific installation rules)
But this breakage all happened before the build bots, likely we can
now have an appropriately
configured build bot which will notice all the breakages that are
likely to occur
by people running the testsuite without it installed, so perhaps it is
a more viable approach
now than I imagined it would be then.
> ---
> gdb/testsuite/gdb.objc/basicclass.m | 6 +++---
> gdb/testsuite/gdb.objc/nondebug.m | 6 +++---
> gdb/testsuite/gdb.objc/objcdecode.m | 6 +++---
> gdb/testsuite/lib/gdb.exp | 10 +++-------
> 4 files changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.objc/basicclass.m b/gdb/testsuite/gdb.objc/basicclass.m
> index d9b3f23954c..d1d54dfff19 100644
> --- a/gdb/testsuite/gdb.objc/basicclass.m
> +++ b/gdb/testsuite/gdb.objc/basicclass.m
> @@ -1,7 +1,7 @@
> #include <stdio.h>
> -#include <objc/Object.h>
> +#include <Foundation/NSObject.h>
>
> -@interface BasicClass: Object
> +@interface BasicClass: NSObject
> {
> id object;
> }
> @@ -75,7 +75,7 @@ const char *_NSPrintForDebugger(id object)
> {
> /* This is not really what _NSPrintForDebugger should do, but it
> is a simple test if gdb can call this function */
> - if (object && [object respondsTo: @selector(myDescription)])
> + if (object)
> return [object myDescription];
>
> return NULL;
> diff --git a/gdb/testsuite/gdb.objc/nondebug.m b/gdb/testsuite/gdb.objc/nondebug.m
> index 352a71c30e3..1ab876443a4 100644
> --- a/gdb/testsuite/gdb.objc/nondebug.m
> +++ b/gdb/testsuite/gdb.objc/nondebug.m
> @@ -1,11 +1,11 @@
> #include <stdio.h>
> -#include <objc/Object.h>
> +#include <Foundation/NSObject.h>
>
> -@interface NonDebug: Object
> +@interface NonDebug: NSObject
> {
> }
> @end
> -@interface NonDebug2: Object
> +@interface NonDebug2: NSObject
> {
> }
> @end
> diff --git a/gdb/testsuite/gdb.objc/objcdecode.m b/gdb/testsuite/gdb.objc/objcdecode.m
> index a061661ed93..78ff301f3e0 100644
> --- a/gdb/testsuite/gdb.objc/objcdecode.m
> +++ b/gdb/testsuite/gdb.objc/objcdecode.m
> @@ -1,7 +1,7 @@
> #include <stdio.h>
> -#include <objc/Object.h>
> +#include <Foundation/NSObject.h>
>
> -@interface Decode: Object
> +@interface Decode: NSObject
> {
> }
> - multipleDef;
> @@ -43,7 +43,7 @@ const char *_NSPrintForDebugger(id object)
> {
> /* This is not really what _NSPrintForDebugger should do, but it
> is a simple test if gdb can call this function */
> - if (object && [object respondsTo: @selector(myDescription)])
> + if (object)
> return [object myDescription];
>
> return NULL;
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 856c96771c6..97a9692b4ce 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -6884,15 +6884,11 @@ proc gdb_compile_shlib_pthreads {sources dest options} {
> proc gdb_compile_objc {source dest type options} {
> set built_binfile 0
> set why_msg "unrecognized error"
> - foreach lib {-lobjc -lpthreads -lpthread -lthread solaris} {
> + set base_libs {-lgnustep-base -lobjc}
> + foreach lib {-lpthreads -lpthread -lthread "-lpthread -lposix4"} {
> # This kind of wipes out whatever libs the caller may have
> # set. Or maybe theirs will override ours. How infelicitous.
> - if { $lib == "solaris" } {
> - set lib "-lpthread -lposix4"
> - }
> - if { $lib != "-lobjc" } {
> - set lib "-lobjc $lib"
> - }
> + set lib "$base_libs $lib"
> set options_with_lib [concat $options [list libs=$lib quiet]]
> set ccout [gdb_compile $source $dest $type $options_with_lib]
> switch -regexp -- $ccout {
> --
> 2.49.0
>
next prev parent reply other threads:[~2025-11-17 10:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 1:26 [PATCH 0/7] Objective-C fixes Tom Tromey
2025-11-17 1:27 ` [PATCH 1/7] Reformat gdb.objc tests Tom Tromey
2025-11-17 1:27 ` [PATCH 2/7] Make the gdb.objc tests compile Tom Tromey
2025-11-17 10:09 ` Matt Rice [this message]
2025-11-18 0:51 ` Tom Tromey
2025-11-18 1:12 ` Matt Rice
2025-12-02 16:20 ` Tom Tromey
2025-12-03 15:24 ` Matt Rice
2025-11-17 1:27 ` [PATCH 3/7] Minor fixes to make gdb.objc tests pass Tom Tromey
2025-11-17 1:27 ` [PATCH 4/7] Rename lookup_struct_typedef Tom Tromey
2025-11-17 1:27 ` [PATCH 5/7] Remove a couple Objective-C expression helpers Tom Tromey
2025-11-17 1:27 ` [PATCH 6/7] Avoid crash with "NSString" literals Tom Tromey
2025-11-17 1:27 ` [PATCH 7/7] Rewrite the @selector code Tom Tromey
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='CACTLOFpczLCBcEEeYeaNOWz-csaooGWDMJp=Lja3wE+mJ5bvnQ@mail.gmail.com' \
--to=ratmice@gmail.com \
--cc=gdb-patches@sourceware.org \
--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