alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
357 stars 176 forks source link

Return -DPIC with `pkg-config --cflags alsa` when appropriate #289

Open afq984 opened 1 year ago

afq984 commented 1 year ago

Some build systems (we are using bazel) do not define -DPIC when compiling position independent objects.

When building a alsa module, if PIC is not defined, global.h requires the presence of the snd_dlsym_start symbol, which is absent from libasound.so if alsa itself is built with -DPIC.

https://github.com/alsa-project/alsa-lib/blob/9447e57d7c1602a861635487ca56c452f3472965/include/global.h#L72

If the PIC macro is non-standard I would suggest exposing it via pkg-config so position independent alsa modules can pick up the flag and apply it to the alsa headers appropriately.

perexg commented 1 year ago

It's a third-party module ? This flag is set by configure (libtool) and it is not required for the standard alsa-lib apps (except the modules). I would suggest to add #define PIC 1 line to the third-party module source or build rules.

afq984 commented 1 year ago

yeah we're building an alsa plugin for our audio server (CRAS). We currently add -DPIC to our build rules, and I'm wondering if it make sense for this to exposed from pkg-config. If you think nothing needs to be changed feel free to close this, thanks!