xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.21k stars 790 forks source link

fPIC not applied to static libs #5881

Open maximegmd opened 4 days ago

maximegmd commented 4 days ago

Xmake Version

master

Operating System Version and Architecture

Ubuntu 24.04

Describe Bug

When building on Linux, -fPIC is not passed during compilation of static libraries causing link issues.

To build, I need to add the flag explicitly add_cxflags("-fPIC")

Expected Behavior

-fPIC should be passed to static libraries and required packages to ensure correct linkage.

Project Configuration

https://github.com/tiltedphoques/CyberpunkMP/tree/server-hosting

Additional Information and Error Logs

https://github.com/tiltedphoques/CyberpunkMP/actions/runs/12004901267/job/33460617334

waruqi commented 3 days ago

see https://github.com/xmake-io/xmake/issues/302

You need to add this flag manually, we don't consider adding it automatically internally, which will cause a lot of other problems.