Skip to content
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 unknown argument: '-export-dynamic' on macOS #227

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jponf
Copy link

@jponf jponf commented Dec 3, 2024

Issue #225

Description of changes: Add '-Wl' to instruct clang (default compiler on macOs) to forward argument to linker phase.

Testing done: Manual install via pip install . on macOS Sonoma 14.7.1 and Debian bookworm (gcc) and through the unit test with tox -e py39 -- -s -vv test/unit/test_entry_point.py::test_install_module on macOS and tox -e py310 -- -s -vv test/unit/test_entry_point.py::test_install_module on Debian.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I used the commit message format described in CONTRIBUTING
  • I have used the regional endpoint when creating S3 and/or STS clients (if appropriate)
  • I have updated any necessary documentation, including READMEs

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jponf jponf changed the title Fix unknown argument: '-export-dynamic' macOS Fix unknown argument: '-export-dynamic' on macOS Dec 3, 2024
@jponf
Copy link
Author

jponf commented Dec 5, 2024

@bhaoz or @jswudi Can you please review?

include_dirs=["src/sagemaker_training/c"],
extra_compile_args=["-Wall", "-shared", "-export-dynamic", "-ldl"],
extra_compile_args=["-Wall", "-shared", "-Wl,-export-dynamic", "-ldl"],
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: separate out -Wl and -export-dynamic.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggestion: explore separating out linker and compile args if any, guideline- https://setuptools.pypa.io/en/latest/userguide/ext_modules.html#compiler-and-linker-options

Copy link
Author

@jponf jponf Dec 9, 2024

Choose a reason for hiding this comment

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

I don't understand your suggestion. The -Wl option is a comma separated list of options to forward to the linker. In the link you suggested there is an example where -Wl is joint with the option "-rpath"

then, a linker-specific option like -Wl,-rpath for each element of Extension.runtime_library_dirs,

I did some more tests, gcc accepts the stand-alone -export-dynamic but clang does not, it requires it being passed with "-Wl" to properly forward it to the linker. Additionally, separating "-Wl" and "-export-dynamic" breaks in both gcc and clang since "-Wl" alone is an unrecognized option. Finally, I've tested moving the option to runtime_library_dirs and extra_link_args and only works on the first.

If you want I could move the option to the argument runtime_library_dirs but the value would still be "-Wl,-export-dynamic". The only difference it would make is the order in which the option will be appended into the command to invoke gcc or clang. I'm ok with either change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants