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

MacOS: fix linker flags for SHLIB feature test #6283

Merged
merged 2 commits into from
Jul 17, 2024
Merged

MacOS: fix linker flags for SHLIB feature test #6283

merged 2 commits into from
Jul 17, 2024

Conversation

jeroen
Copy link
Contributor

@jeroen jeroen commented Jul 16, 2024

Amends #6034 by @kevinushey.

The problem is that R CMD SHLIB actually ignores $LDFLAGS; you can easily test this with --dry-run:

#include <omp.h>
int main() {
  return omp_get_num_threads();
}

Above is the test-omp.c from the configure script, and then run it with:

LDFLAGS="-lomp" R CMD SHLIB --dry-run test-omp.c

You can see there is no -lomp in the output at all. The reason why the feature test succeeds anyway on most systems is that R defaults to -undefined dynamic_lookup so it ignores missing libraries.

However, on r-universe we cross compile without -undefined dynamic_lookup and therefore the feature test fails. If we set -lomp in $PKG_LIBS instead the feature test works.

PKG_LIBS="-lomp" R CMD SHLIB --dry-run test-omp.c

I confirmed this fixes the cross compile as well.

@jeroen jeroen requested a review from MichaelChirico as a code owner July 16, 2024 19:11
@MichaelChirico
Copy link
Member

Thanks for the explanation & fix. Looks OK to me, but I'll let @kevinushey chime in as the original author.

Copy link
Contributor

@kevinushey kevinushey left a comment

Choose a reason for hiding this comment

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

LGTM

@MichaelChirico MichaelChirico merged commit ebc185e into Rdatatable:master Jul 17, 2024
4 checks passed
@MichaelChirico
Copy link
Member

Thanks both!

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.

3 participants