dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Fix issue 20297: ld: warning: building for macOS

Open jacob-carlborg opened this issue 5 years ago • 18 comments

What's missing:

  • [x] Tests
  • [x] Don't hardcode the current SDK
  • [x] Don't hardcode the current platform version

I'm guessing we can hardcode the platform for now since DMD doesn't support cross-compiling.

jacob-carlborg avatar Oct 12 '19 19:10 jacob-carlborg

Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Auto-close Bugzilla Severity Description
20297 normal ld: warning: building for macOS

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#10476"

dlang-bot avatar Oct 12 '19 19:10 dlang-bot

Not WIP anymore.

jacob-carlborg avatar Oct 30 '19 20:10 jacob-carlborg

Don't know why the tests are failing. They work locally.

jacob-carlborg avatar Nov 03 '19 20:11 jacob-carlborg

What version is the machine ? I doubt it's Catalina.

Geod24 avatar Nov 04 '19 00:11 Geod24

One machine is running Darwin 13 and one is running Darwin 15. I think Catalina is at least on Darwin 19. One is running Clang 6 which is really old and the other one Clang 8 which is quite old.

I developed this on Mojave so it’s not dependent on Catalina.

Perhaps I can check the version and only add the new load command if it’s recent enough.

jacob-carlborg avatar Nov 04 '19 08:11 jacob-carlborg

Perhaps I can check the version and only add the new load command if it’s recent enough.

Sounds like the way to go.

PetarKirov avatar Nov 04 '19 11:11 PetarKirov

Seems like the LC_BUILD_VERSION load command was added in Xcode 10. In previous version there was a LC_VERSION_MIN_MACOSX load command. I can add support for that as well.

jacob-carlborg avatar Nov 04 '19 19:11 jacob-carlborg

Now handles both LC_BUILD_VERSION and LC_VERSION_MIN_MACOSX. Let's see what the CI pipelines say.

jacob-carlborg avatar Nov 07 '19 20:11 jacob-carlborg

That warning is still all over the place :(

Looks like it shows in 2 different ways tho. When compiling DMD:

ld: warning: object file (../generated/osx/release/64/parser.a(array_2c6_60c.o)) was built for newer OSX version (10.11.6) than being linked (10.9)

When compiling the test suite:

ld: warning: object file (../../phobos/{{RESULTS_DIR}}/osx/release/64/libphobos2.a(object_3c_775.o)) was built for newer OSX version (10.11.6) than being linked (10.11)

Geod24 avatar Nov 08 '19 01:11 Geod24

That’s probably correct. There’s an environment variable I need to take into account as well.

I’ve seen this warning with Clang and LDC as well.

jacob-carlborg avatar Nov 08 '19 08:11 jacob-carlborg

Not sure why it segfaults though on one of the machines.

jacob-carlborg avatar Nov 08 '19 08:11 jacob-carlborg

I still don't know how to debug the segfault in the failing test since it doesn't happen locally.

jacob-carlborg avatar Nov 16 '19 12:11 jacob-carlborg

I still don't know how to debug the segfault in the failing test since it doesn't happen locally.

I had an old VM running a version of macOS where I could reproduce the failure. Hopefully it should be fixed now.

jacob-carlborg avatar Nov 17 '19 10:11 jacob-carlborg

Anyone that understands what the dshell/sameenv.d test is supposed to do?

jacob-carlborg avatar Nov 18 '19 18:11 jacob-carlborg

It came from this PR: https://github.com/dlang/dmd/pull/8121 and seems to be making sure that dmd -run doesn't pollute the environment.

I assume something in CoreFoundation is setting __CF_USER_TEXT_ENCODING=0x1F6:0:0 in the environment which I think is the only change in env that's causing that test to fail

benjones avatar Nov 22 '19 18:11 benjones

Needs a rebase

MoonlightSentinel avatar Apr 01 '20 16:04 MoonlightSentinel

The warnings don't appear anymore. Apple must have changed something. Not sure if it's still interesting to have these load commands.

jacob-carlborg avatar Apr 01 '20 17:04 jacob-carlborg

macOS 13 coverage tests on mainline have suddenly began failing with:

ld: multiple errors: symbol count from symbol table and dynamic symbol table differ in '/Users/runner/work/dmd/dmd/generated/build.o' in '/Users/runner/work/dmd/dmd/generated/build.o'; address=0x0 points to section(2) with no content in '/Users/runner/dlang/dmd-2.107.0/osx/lib/libphobos2.a[3233](config_a98_4c3.o)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
Error: Process completed with exit code 1.

Time for a rebase?

ibuclaw avatar Feb 11 '24 20:02 ibuclaw