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

[Driver] Fix linking with -lm on Solaris #65632

Merged
merged 1 commit into from
Sep 7, 2023

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Sep 7, 2023

As noticed in D158846, the Solaris driver deviates from other targets in that it links every executable with -lm, but doesn't for shared objects. For C code, this is unnecessary, while for C++ libm is always needed, even for shared objects.

This patch fixes this by following the Gnu.cpp precedent. It adjusts the solaris-ld.c test accordingly, adding some more tests.

Tested on amd64-pc-solaris2.11, sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.

As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared objects.
For C code, this is unnecessary, while for C++ `libm` is always needed,
even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent.  It adjusts the
`solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
@rorth rorth requested a review from MaskRay September 7, 2023 16:12
@rorth rorth requested a review from a team as a code owner September 7, 2023 16:12
@github-actions github-actions bot added the clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' label Sep 7, 2023
@rorth rorth merged commit 1e6b0df into llvm:main Sep 7, 2023
1 of 2 checks passed
avillega pushed a commit to avillega/llvm-project that referenced this pull request Sep 11, 2023
As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared
objects. For C code, this is unnecessary, while for C++ `libm` is always
needed, even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent. It adjusts
the `solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
tru pushed a commit that referenced this pull request Nov 13, 2023
As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared
objects. For C code, this is unnecessary, while for C++ `libm` is always
needed, even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent. It adjusts
the `solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.

(cherry picked from commit 1e6b0df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants