Closed ngrewe closed 4 years ago
Is this being linked with BFD ld? It looks like it's a known bug where ld.bfd -r discards the sections too early and you end up with the categories not existing in the final binary. Linking with Gold or LLD should fix it.
Ah right, I think we ran into some similar issues with GNUstep on Android that were fixed by using the Gold linker.
Is there a way we can modify GNUstep make to always use the Gold or LLD linker with the 2.0 runtime so no one has to run into this again?
I was able to compile and run this program with no issue under Ubuntu 19.04 using clang-8, and ~the default ld which happens to be symlinked to ld.bfd~ correction: using ld.gold. The build script I used was this one: https://github.com/plaurent/gnustep-build/blob/master/ubuntu-19.04-clang-8.0-runtime-2.0/GNUstep-buildon-ubuntu1904.sh
It would be interesting to try to replicate your setup.
Did you compile clang-9 from scratch, or did you get it from a repository? Did you have the following set: export RUNTIME_VERSION=gnustep-2.0 ?
Scratch that comment about LD being ld.bfd -- was actually using ld.gold
Turns out to be the linker issue… sorry for the noise!
Is there a way we can modify GNUstep make to always use the Gold or LLD linker with the 2.0 runtime so no one has to run into this again?
I'll try to put together an autoconf check for this issue.
@ngrewe, either gold or lld works, though there are a few things that trigger issues with LLD (SOGo, for example) and require GOLD. If you look in the FreeBSD ports tree for things that have gnustep on the USES line and are marked LLD_UNSAFE
you can find some examples.
FYI: I've got a PR over at gnustep/tools-make#4 that partly addresses this. Unfortunately it turned out that you can't easily reproduce the ld.bfd problem in a conftest, but the least we can do is to provide the user with some indication that they might be using a linker that won't produce working binaries…
I'm currently seeing problems with message dispatch when compiling gnustep-base using the 2.0 runtime ABI. This test program, compiled under Ubuntu 18.04 with clang-9, current libobjc master (8249036) and gnustep-base master (7d1a5cceb), fails with a stack overflow due to a loop created by failing to raise an
NSInvalidArgumentException
during message forwarding.This is the start of the backtrace:
The first interesting stack frame is 41666:
+leakAt:
is defined in a category (cf.Additions/NSObject+GNUstepBase.m
), so it shouldn't trigger second-chance dispatch.Things get interesting again in frame 41659. At this point, base has decided that it cannot forward the message, and tries to raise the NSInvalidArgumentException, which then fails itself because
[NSString stringWithFormat:arguments:]
cannot be resolved:Now
+stringWithFormat:arguments:
is also defined in a category (cf.Additions/NSString+GNUstepBase.m
). So my working theory currently is that there is some problem either with class methods in categories, or with categories in different compilation units (we already have tests for instance methods in the same compilation unit).I'll try and produce some reduced test cases for that soon.