-
-
Notifications
You must be signed in to change notification settings - Fork 637
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: Add -arch x86_64 to CXXFLAGS on macOS ARM64 to Resolve Linker Errors in Mixed C++ and D Testss #21012
base: master
Are you sure you want to change the base?
Conversation
This merge is necessary to bring the latest changes from the master branch into the fix-cxxflags-arch-x86_64 branch. The issue was discovered while running `make test` on macOS arm64. This ensures that the fix for adding `-arch x86_64` to CXXFLAGS remains compatible with recent updates in the main branch and resolves the problem encountered during testing.
This merge is necessary to bring the latest changes from the master branch into the fix-cxxflags-arch-x86_64 branch. The issue was discovered while running `make test on masOS arm64. This ensures that the fix for adding `-arch x86_64` to CXXFLAGS remains compatible with recent updates in the main branch and resolves the problem encountered during testing.
Thanks for your pull request and interest in making D better, @gulugulubing! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. 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#21012" |
#17035 shows that this isn't needed, on an arm64 macOS runner. The reason AFAIU being that both DMD and the testrunner are x86_64 executables, and in that case, the invoked universal |
Thank you for your feedback! I understand the discussion in the referenced issue is about building and running DMD natively on ARM64 macOS, which is a different scenario from my PR. My issue occurs during the testing phase after building, specifically when running ld: warning: ignoring file '/dlang/dmd/compiler/test/test_results/runnable_cxx/d/test6716.cpp.o': found architecture 'arm64', required architecture 'x86_64' |
Yeah the PR is a bit messy (still in draft) - but what's key is that it adds a Which Lines 131 to 132 in a4cbc08
So I guess it's plausible that What we definitely don't want are hardcoded |
My make version is : As a newcomer to contributing, I'm still getting familiar with the D language build process. Modifying the complex scripts or Makefile to enforce arch -x86_64 feels a bit challenging for me at this stage. Therefore, I tried making the change directly in the test files instead. While I understand this approach may seem less elegant, it appeared to be simpler and more controllable for me as a beginner. I appreciate your understanding and guidance! |
No worries, and thx for contributing! :) You could add some implicit args after this line: dmd/compiler/test/tools/d_do_test.d Line 741 in a4cbc08
E.g.: // DMD on macOS: force Apple clang to produce x86_64 code (on arm64 too), like DMD
version (DigitalMars) version (OSX)
testArgs.cxxflags ~= " -arch x86_64"; Edit: Or append them after this: dmd/compiler/test/tools/d_do_test.d Lines 1108 to 1109 in a4cbc08
|
Thank you! I tried modifying the |
CI is green now, this good to go? |
Have you read what I wrote? No hardcoded args in these test files. |
Problem
On Apple Silicon, the default architecture for C++ compilers is ARM64,
which conflicts with DMD's x86_64 output. This causes linker errors when
building mixed C++ and D projects during
make test
.Solution
This change adds
-arch x86_64
to the CXXFLAGS to ensure the C++ compilergenerates x86_64 objects on macOS.
Testing