kaniini / libucontext

ucontext implementation featuring glibc-compatible ABI
Other
106 stars 41 forks source link

libucontext not functional under Gentoo (-DEXPORT_UNPREFIXED disabled when alternate CFLAGS present) #39

Closed andrewathalye closed 2 years ago

andrewathalye commented 2 years ago

Under Gentoo, it is common practice to include custom CFLAGS, particularly "-march=native" in /etc/portage/make.conf. libucontext's Makefile appears to encounter problems when this is the case, with a telltale sign of these problems being -DEXPORT_UNPREFIXED not being correctly applied, and the resulting libucontext.so thus not containing any unprefixed weak symbols.

I am unaware of exactly what the issue is with the Makefile, however for the time being this can be worked around by using "<...> -DEXPORT_UNPREFIXED" as one's CFLAGS or hardcoding the desired CFLAGS into the Makefile.

andrewathalye commented 2 years ago

libucontext-1.1-unprefixed.patch.txt It took me a little bit to figure out the exact issue, but it looks like the problem is because Gentoo's CFLAGS directly overwrites the one specified in the Makefile. The below patch is my best "quick-fix", but in truth it might be best to use a separate variable for UNPREFIXED since CFLAGS is overwritten here.

Edit: A revised patch was attached with better names.

kaniini commented 2 years ago

That patch is not acceptable, fix it so that Gentoo's CFLAGS are merged with the ones chosen by the build system.

andrewathalye commented 2 years ago

I'll work on modifying the Gentoo ebuild to invoke make as CFLAGS="<...>" make -j12 then, which should hopefully make it so that gmake doesn't replace / override the Makefile CFLAGS.

andrewathalye commented 2 years ago

Here are two potential solutions: 1 Concatenate supplied CFLAGS with the ones in the Makefile 2 Only specify CFLAGS in Makefile if unset, merely add -DEXPORT_UNPREFIXED, etc. to existing CFLAGS In either case the Gentoo ebuild was changed to call make so that CFLAGS wasn't directly overridden, but the Makefile then overwrites the specified CFLAGS itself on line 19.

I've attached both ideas to this post. Gentoo would prefer for -Ggdb3 not to be added if we specify our own CFLAGS (since it's for a release build).

libucontext-concat.patch.txt libucontext-set-cflags-if-unset.patch.txt

andrewathalye commented 2 years ago

Update: Gentoo has merged the set cflags if unset patch downstream. I'll close this as the problem has now been addressed and, even if no patches from above are merged here, the new Gentoo ebuild will not directly override libucontext's CFLAGS, so it should work normally.

kaniini commented 2 years ago

I merged the set cflags if unset patch. It will be in libucontext 1.2.