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

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

Closed
andrewathalye opened this issue Feb 4, 2022 · 6 comments

Comments

@andrewathalye
Copy link

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
Copy link
Author

andrewathalye commented Feb 4, 2022

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
Copy link
Owner

kaniini commented Feb 4, 2022

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

@andrewathalye
Copy link
Author

andrewathalye commented Feb 4, 2022

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
Copy link
Author

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
Copy link
Author

andrewathalye commented Feb 8, 2022

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
Copy link
Owner

kaniini commented Feb 13, 2022

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

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

No branches or pull requests

2 participants