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

Build plugin support library with PIC on Linux and BSD #100

Merged
merged 3 commits into from
Dec 5, 2023

Conversation

royshil
Copy link
Contributor

@royshil royshil commented Nov 13, 2023

Description

Adding -fPIC on Linux when compiling the libplugin-support.a static lib, otherwise some Linux OSs build complain e.g.

/usr/bin/ld: libplugin-support.a(plugin-support.c.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: bad value

Motivation and Context

Fixing Linux build for OSs such as Fedora.

How Has This Been Tested?

Built on Mac, Windows and Linux (Ubuntu).

Types of changes

Effectively a bugfix?

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@royshil royshil changed the title Add fPIC to plusing-support in helpers_common.cmake Add fPIC to pluging-support.a in helpers_common.cmake Nov 21, 2023
@PatTheMav
Copy link
Member

Using an OBJECT library would probably be better, but alas CMake doesn't support them with universal (x86_64 and arm64) macOS targets, so we are kinda stuck with static libraries.

For some reason gcc does not assume PIC automatically for static x86_64 builds, so this seems correct.

Co-authored-by: Patrick Heyer <[email protected]>
@royshil
Copy link
Contributor Author

royshil commented Dec 4, 2023

Thanks @PatTheMav !

@PatTheMav
Copy link
Member

One last thing, I'd prefer if the PR title and commit title would read something like:

Build plugin support library with PIC on Linux and BSD

It's more generic from a project POV (calling it "position-independent code" would be even better but probably run afoul of commit message limits).

@royshil royshil changed the title Add fPIC to pluging-support.a in helpers_common.cmake Build plugin support library with PIC on Linux and BSD Dec 4, 2023
@PatTheMav
Copy link
Member

Please squash your changes into logical units and ensure correct naming for all commits. Otherwise the PR looks good.

@PatTheMav PatTheMav merged commit 0292985 into obsproject:master Dec 5, 2023
6 checks passed
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