Skip to content

Replace -fPIC with POSITION_INDEPENDENT_CODE.#2383

Merged
lemire merged 1 commit intosimdjson:masterfrom
xkszltl:pic
Jun 30, 2025
Merged

Replace -fPIC with POSITION_INDEPENDENT_CODE.#2383
lemire merged 1 commit intosimdjson:masterfrom
xkszltl:pic

Conversation

@xkszltl
Copy link
Contributor

@xkszltl xkszltl commented Jun 30, 2025

CMake has cross-platform support for -fPIC

@lemire
Copy link
Member

lemire commented Jun 30, 2025

One wonders whether PIC is needed at all... CMake already defaults on PIC for shared libraries.

https://cmake.org/cmake/help/v4.1/prop_tgt/POSITION_INDEPENDENT_CODE.html

@xkszltl
Copy link
Contributor Author

xkszltl commented Jun 30, 2025

Could be PIC for static lib right? Whatever .a that got linked into .so in downstream needs to be built with PIC.

@lemire
Copy link
Member

lemire commented Jun 30, 2025

But if you need PIC in the static library, why won't you set CMAKE_POSITION_INDEPENDENT_CODE?

@xkszltl
Copy link
Contributor Author

xkszltl commented Jun 30, 2025

I don't know why this line is there in the first place.

@xkszltl
Copy link
Contributor Author

xkszltl commented Jun 30, 2025

This PR is only to make it "less wrong".
Whether it can be totally removed is another story.

@lemire
Copy link
Member

lemire commented Jun 30, 2025

I'll merge because you are improving things. I'll open an issue.

@lemire
Copy link
Member

lemire commented Jun 30, 2025

Running tests first.

@xkszltl
Copy link
Contributor Author

xkszltl commented Jun 30, 2025

Although I do want to point out it is not always possible to set a single CMAKE_POSITION_INDEPENDENT_CODE globally, because that can also affect other sub-project built in that run.
Ideally, as long as the performance is good, we should just set PIC for all builds of simdjson, so that downstream user do not need to worry about how they build simdjson.

@lemire lemire merged commit 9376677 into simdjson:master Jun 30, 2025
71 of 75 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