Skip to content

Fix issue 20297: ld: warning: building for macOS#10476

Open
jacob-carlborg wants to merge 2 commits intodlang:masterfrom
jacob-carlborg:20297-build-for-macOS-warning
Open

Fix issue 20297: ld: warning: building for macOS#10476
jacob-carlborg wants to merge 2 commits intodlang:masterfrom
jacob-carlborg:20297-build-for-macOS-warning

Conversation

@jacob-carlborg
Copy link
Contributor

@jacob-carlborg jacob-carlborg commented Oct 12, 2019

What's missing:

  • Tests
  • Don't hardcode the current SDK
  • Don't hardcode the current platform version

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

@dlang-bot
Copy link
Contributor

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"

Comment on lines +414 to +416
uint platform = PLATFORM_MACOS;
uint minos = 659200; // 10.15
uint sdk = 659200; // 10.15
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three attributes can be configured when compiling with Clang. Is this something we want to support? By default it will use the current platform and current SDK to set these values.

@jacob-carlborg jacob-carlborg added the Review:WIP Work In Progress - not ready for review or pulling label Oct 12, 2019
@jacob-carlborg jacob-carlborg changed the title Fix issue 20297: ld: warning: building for macOS [WIP] Fix issue 20297: ld: warning: building for macOS Oct 12, 2019
@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch from 94029b8 to 47707dd Compare October 29, 2019 12:30
@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch 2 times, most recently from a9df814 to e2901a7 Compare October 30, 2019 20:09
@jacob-carlborg jacob-carlborg changed the title [WIP] Fix issue 20297: ld: warning: building for macOS Fix issue 20297: ld: warning: building for macOS Oct 30, 2019
@jacob-carlborg jacob-carlborg removed the Review:WIP Work In Progress - not ready for review or pulling label Oct 30, 2019
@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch from e2901a7 to 1e8fff8 Compare October 30, 2019 20:18
@jacob-carlborg
Copy link
Contributor Author

Not WIP anymore.

@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch 6 times, most recently from b9eb995 to 797916e Compare November 3, 2019 14:19
@jacob-carlborg
Copy link
Contributor Author

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

@Geod24
Copy link
Member

Geod24 commented Nov 4, 2019

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

@jacob-carlborg
Copy link
Contributor Author

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.

@PetarKirov
Copy link
Member

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

Sounds like the way to go.

@jacob-carlborg
Copy link
Contributor Author

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 jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch 2 times, most recently from f385ebd to 3c99b30 Compare November 7, 2019 20:36
@jacob-carlborg
Copy link
Contributor Author

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

@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch from 3c99b30 to 41f6d3f Compare November 7, 2019 20:39
@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch 3 times, most recently from c6a6df0 to 917de2d Compare November 15, 2019 19:28
@jacob-carlborg
Copy link
Contributor Author

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

@jacob-carlborg jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch 2 times, most recently from b289067 to 656f503 Compare November 17, 2019 10:23
@jacob-carlborg
Copy link
Contributor Author

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 jacob-carlborg force-pushed the 20297-build-for-macOS-warning branch from 656f503 to 38ca640 Compare November 17, 2019 10:37
@jacob-carlborg
Copy link
Contributor Author

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

@benjones
Copy link
Contributor

It came from this PR: #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

@MoonlightSentinel
Copy link
Contributor

Needs a rebase

@jacob-carlborg
Copy link
Contributor Author

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

@ibuclaw
Copy link
Member

ibuclaw commented Feb 11, 2024

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 added a commit to ibuclaw/dmd that referenced this pull request Feb 11, 2024
…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>
ibuclaw added a commit to ibuclaw/dmd that referenced this pull request Feb 11, 2024
…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>
ibuclaw added a commit to ibuclaw/dmd that referenced this pull request Feb 11, 2024
…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>
ibuclaw added a commit to ibuclaw/dmd that referenced this pull request Feb 11, 2024
…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>
ibuclaw added a commit to ibuclaw/dmd that referenced this pull request Feb 18, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants