Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 912237

Summary: sys-devel/clang-common: Set -fPIE for current CHOST only
Product: Gentoo Linux Reporter: Violet Purcell <vimproved>
Component: Current packagesAssignee: LLVM support project <llvm>
Status: RESOLVED FIXED    
Severity: normal CC: alex_y_xu, herrtimson, ionen, sam
Priority: Normal Keywords: PullRequest
Version: unspecified   
Hardware: All   
OS: Linux   
See Also: https://bugs.gentoo.org/show_bug.cgi?id=901247
https://github.com/gentoo/gentoo/pull/32367
Whiteboard:
Package list:
Runtime testing required: ---

Description Violet Purcell 2023-08-13 17:46:40 UTC
Currently, sys-devel/clang-common sets -fPIE globally. However, this can cause issues for platforms where it's not supported (such as windows.) This is the reason that wine currently fails with clang and USE=mingw; the configure check for -target x86_64-windows fails due to -fPIE being globally enabled, and then the configure check for -mabi=ms fails due to -target x86_64-windows not being appended. The other potential solution would be to install config files for the specific CHOSTs where -fPIE should be disabled such as x86_64-unknown-windows-msvc.
Comment 1 Violet Purcell 2023-08-13 17:48:44 UTC
(In reply to Violet Purcell from comment #0)
> is the reason that wine currently fails with clang and USE=mingw; the
*meant USE=-mingw
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-14 01:50:51 UTC
Yeah, we need to do this.

I suspect I chose the existing setup because we backported the config support before it was upstream in a useful state.
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-08-14 01:52:08 UTC
I'll handle this later along with bug 912223.
Comment 4 Larry the Git Cow gentoo-dev 2023-08-18 09:22:56 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43a24d68531ab4ca9ad83d686a620cd2937dbf4f

commit 43a24d68531ab4ca9ad83d686a620cd2937dbf4f
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2023-08-18 02:06:05 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2023-08-18 09:22:32 +0000

    sys-devel/clang-common: only add default configs (e.g. -fPIE) for native tools
    
    We don't want to add our configs to 'clang', 'clang++', etc because that might
    be used for crosscompilation.
    
    Use the prefixed CHOST versions instead.
    
    [I suspect I didn't do this before because the old config logic, before we improved
    it upstream, didn't have the fallback behaviour for clang->${CHOST}-clang or similar.]
    
    Closes: https://bugs.gentoo.org/901247
    Closes: https://bugs.gentoo.org/912237
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-devel/clang-common/clang-common-17.0.0.9999.ebuild               | 5 ++++-
 sys-devel/clang-common/clang-common-17.0.0_rc2-r1.ebuild             | 5 ++++-
 sys-devel/clang-common/clang-common-18.0.0.9999.ebuild               | 5 ++++-
 sys-devel/clang-common/clang-common-18.0.0_pre20230803.ebuild        | 5 ++++-
 ..._pre20230810.ebuild => clang-common-18.0.0_pre20230810-r1.ebuild} | 5 ++++-
 5 files changed, 20 insertions(+), 5 deletions(-)
Comment 5 Ionen Wolkens gentoo-dev 2023-08-18 09:28:50 UTC
(In reply to Violet Purcell from comment #1)
> USE=-mingw
Just ftr there's no plans to officially support this configuration w/ clang for the time being, see also [1]. So USE=mingw remains forced on llvm profiles.

Albeit, with that fix and >=clang-17, this is still usable if really wanted (without modifying the ebuild) by unforcing mingw and doing:

USE="-abi_x86_32 -wow64 -mingw" EXTRA_ECONF="--enable-archs=x86_64,i386" emerge ">=wine-vanilla-8.13" (or staging, not supported with wine-proton yet)

May optionally want to set CROSSCFLAGS and CROSSLDFLAGS given they won't be handled by the ebuild (do ensure usable for the target). And even if wanted to, strip-unsupported-flags / test-flags-* are not usable given it'll lack wine's runtime to actually compile anything unlike mingw64-toolchain.
Comment 6 Ionen Wolkens gentoo-dev 2023-08-18 09:31:00 UTC
(In reply to Ionen Wolkens from comment #5)
> (In reply to Violet Purcell from comment #1)
> > USE=-mingw
> Just ftr there's no plans to officially support this configuration w/ clang
> for the time being, see also [1]. So USE=mingw remains forced on llvm
Oops, forgot the link

[1] https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3fcaa1a69c6b