-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix macOS ld: multiple errors: symbol count from symbol table and dynamic symbol table differ #16178
Conversation
Thanks for your pull request, @ibuclaw! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#16178" |
7e6cdb2
to
3392f40
Compare
|
4d61b66
to
8dd990b
Compare
It looks like encoding this information into the binary isn't working, but passing it via linker flags works just fine. Someone (not me) will have to repurpose the OSX version handling for |
If no one picks this up, I'm going to start downgrading all macOS pipelines to ignore failures, as this is blocking other work. |
I think all that link.d needs is this code: argv.push("-L-platform_version");
argv.push("-Lmacos");
argv.push("-L0.0"); to be added here https://github.com/dlang/dmd/blob/master/compiler/src/dmd/link.d#L610. I just picked up the linker flags you used in |
As far as I can tell, the syntax of the option is:
https://opensource.apple.com/source/ld64/ld64-530/doc/man/man1/ld.1.auto.html
The sdk_version doesn't seem to be important, but the min_version would be rejected if invalid.
getenv and sscanf (the first commit in this PR is a simplified version of #10476 - c01f8cc) I wouldn't hard-code
|
Hmm, so building the compiler itself with the host compiler is no problem at all, but compiling |
I think |
|
Plus we have dmd/.github/workflows/main.yml Line 85 in 6aa84ab
which should AFAIK prevent using the latest Xcode features/regressions. |
Oh of course it is; I just somehow totally missed that you extend them here in this PR. facepalm [The added tab-indentation doesn't really help.] |
Right, I can see a warning about both conflicting in the CI logs ( I could set this to |
10.9 good, 11.0 fails 10.12 fails 10.11 fails 10.10 fails 10.9 second attempt fails. |
Alright, looks like maybe |
|
Removing macOS as a required pipeline. |
They must have changed the runner base image; the CI job headers should include the image version somewhere. The macOS-13 image history is tracked in https://github.com/actions/runner-images/commits/main/images/macos/macos-13-Readme.md; the last change was merged on February 14th (actions/runner-images#9292), but the image version is |
So in that latest image bump, they changed the default Xcode version from v14 to v15. Running Edit: #16194 |
It was first seen to fail 2 weeks ago. https://github.com/dlang/dmd/actions/runs/7792736255/job/21251287831 It's probably been a very slow rollout. |
Oh wow right, using that image already back then (February 6th):
So indeed, looks like the rollout is extremely slow, and starts way before the image readme.md is updated... |
Github search to the rescue. if ( hasIndSymTab && (symCount != indSymCount))
return Error("symbol count from symbol table and dynamic symbol table differ");
Simplifying the above for mere mortals (such as myself). dysymtab_cmd.nlocalsym = local_symbuf.length;
dysymtab_cmd.iextdefsym = dysymtab_cmd.nlocalsym;
dysymtab_cmd.nextdefsym = public_symbuf.length;
dysymtab_cmd.iundefsym = dysymtab_cmd.iextdefsym + dysymtab_cmd.nextdefsym;
dysymtab_cmd.nundefsym = extern_symbuf.length + comdef_symbuf.length;
symtab_cmd.nsyms = dysymtab_cmd.nlocalsym +
dysymtab_cmd.nextdefsym +
dysymtab_cmd.nundefsym; -> const prop dysymtab_cmd.iundefsym = local_symbuf.length + public_symbuf.length;
dysymtab_cmd.nundefsym = extern_symbuf.length + comdef_symbuf.length;
symtab_cmd.nsyms = local_symbuf.length + public_symbuf.length + dysymtab_cmd.nundefsym; So linker should see: symCount = symtab_cmd.nsyms;
indSymCount = dysymtab_cmd.iundefsym + dysymtab_cmd.nundefsym; Its a bit convoluted, but they add up to the same number. Which then means this might just be corruption of the data structure as the linker reads in the object. |
I don't know entirely what's up with Apple's static linker, but I do know they wrote a new one recently, hence the Anyway, as @ibuclaw posted above, the number of symbols in the symbol table and dynamic symbol table need to be the same. A quick investigation shows this:
extern (C) int printf(const char*, ...);
void main()
{
printf("foo\n");
}
This gives the following output: DMD:LC_SYMTAB: LC_DYSYMTAB: LDC:LC_SYMTAB: LC_DYSYMTAB:
As mentioned above, the number of symbols are calculated as:
According to Also, trying to print the indirect symbol table give these results:
So DMD is doing something wrong. |
Knowing those ten symbol names might help. But as far as I can tell, writing a wrong number to object is improbable. |
This is ridiculous dmd/compiler/src/dmd/backend/machobj.d Lines 1409 to 1430 in 9471b25
|
…amic symbol table differ Encode macosx_version_min or build_version into the object file, originally authored by @jacob-carlborg in dlang#10476. This has been simplified to omit parsing the SDK version. Based on what I see GCC is doing (`-platform_version macos $version_min 0.0`), this information is not required in order for things to work. Co-authored-by: Jacob Carlborg <doob@me.com>
… and dynamic symbol table differ" This reverts commit c01f8cc.
d7d50b0
to
9a12c7d
Compare
The above shows all symbols. Unfortunately I haven't figured out which symbol table the |
BTW, DMD can now cross-compile. LLVM contains the necessary tools to inspect the object files (
If you need access to a real Mac, you can also borrow a GitHub Action runner using this action: https://github.com/marketplace/actions/debugging-with-tmate. I've used it a lot to debug pipelines and my own action. |
I count no fewer than half a dozen issues. #16194 is in and there's no appetite to address them for now. |
Encode macosx_version_min or build_version into the object file, originally authored by @jacob-carlborg in #10476.
This has been simplified to omit parsing the SDK version. Based on what I see GCC is doing (
-platform_version macos $version_min 0.0
), this information is not required in order for things to work.Either this will fix the new ld errors, or we'll have to start adding
-L-ld_classic
to the linker command.https://forum.dlang.org/thread/jwmpdecwyazcrxphttoy@forum.dlang.org