Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 862540 - =sys-libs/compiler-rt-14.0.6 merges no files but a Readme file on arm64
Summary: =sys-libs/compiler-rt-14.0.6 merges no files but a Readme file on arm64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: LLVM support project
URL:
Whiteboard:
Keywords:
Depends on: 877045
Blocks:
  Show dependency tree
 
Reported: 2022-07-31 13:29 UTC by tt_1
Modified: 2022-10-13 22:31 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
compressed build log from aarch64-cross (build.log.gz,3.11 KB, application/gzip)
2022-07-31 13:29 UTC, tt_1
Details
output from emerge --info (emerge-info,7.76 KB, text/plain)
2022-07-31 13:30 UTC, tt_1
Details
build.log (sam, successful build) (file_862540.txt,15.64 KB, text/plain)
2022-07-31 21:52 UTC, Sam James
Details
emerge --info (sam, successful build) (file_862540.txt,5.97 KB, text/plain)
2022-07-31 21:52 UTC, Sam James
Details
bad qlop list (file_862540.txt,64.89 KB, text/plain)
2022-08-01 03:50 UTC, Sam James
Details
compressed build log from aarch64-cross (cross-build.log.gz,3.74 KB, application/gzip)
2022-08-03 06:49 UTC, tt_1
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tt_1 2022-07-31 13:29:22 UTC
Created attachment 796147 [details]
compressed build log from aarch64-cross

emerge-aarch64-unknown-linux-gnu -pv compiler-rt 

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] sys-libs/compiler-rt-14.0.6:14.0.6::gentoo to /usr/aarch64-unknown-linux-gnu/ USE="-clang -debug -test -verify-sig" 0 KiB

and will leave these files to be installed: 

>>> Completed installing sys-libs/compiler-rt-14.0.6 into /var/tmp/portage/portage/sys-libs/compiler-rt-14.0.6/image

 * Final size of build directory: 48752 KiB (47.6 MiB)
 * Final size of installed tree:      4 KiB

./
./usr/
./usr/share/
./usr/share/doc/
./usr/share/doc/compiler-rt-14.0.6/
./usr/share/doc/compiler-rt-14.0.6/README.txt.bz2
>>> Done.
Comment 1 tt_1 2022-07-31 13:30:22 UTC
Created attachment 796150 [details]
output from emerge --info
Comment 2 tt_1 2022-07-31 13:47:52 UTC
ehr, I just confirmed the issue on native aarch64. 

Is this intended? 

the files are shipped on Arch Linux arm port: 

cd /usr/lib/clang/14.0.6/lib/linux && ls | grep crt

clang_rt.crtbegin-aarch64.o
clang_rt.crtend-aarch64.o
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-31 20:29:33 UTC Comment hidden (obsolete)
Comment 4 tt_1 2022-07-31 21:04:47 UTC Comment hidden (obsolete)
Comment 5 tt_1 2022-07-31 21:31:05 UTC
lets forget about the cross compile, it will most likely be broken at runtime anyway


the native compile works for 14.0.6 if built with gcc, so USE="-clang -debug -test -verify-sig" emerge -av =compiler-rt-14.0.6 -1 will result in installing no files but the readme. 


how does the ebuild detect what ninja has to do? 

>>> Compiling source in /var/tmp/portage/sys-libs/compiler-rt-14.0.6/work/compiler-rt ...
 * Source directory (CMAKE_USE_DIR): "/var/tmp/portage/sys-libs/compiler-rt-14.0.6/work/compiler-rt"
 * Build directory  (BUILD_DIR):     "/var/tmp/portage/sys-libs/compiler-rt-14.0.6/work/compiler-rt-14.0.6_build"
ninja -v -j4 -l0
ninja: no work to do.
>>> Source compiled.
Comment 6 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-31 21:51:00 UTC Comment hidden (obsolete)
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-31 21:52:38 UTC Comment hidden (obsolete)
Comment 8 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-07-31 21:52:58 UTC Comment hidden (obsolete)
Comment 9 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 03:50:01 UTC Comment hidden (obsolete)
Comment 10 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 03:50:55 UTC Comment hidden (obsolete)
Comment 11 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 03:56:56 UTC
(In reply to Sam James from comment #7)
> Created attachment 796279 [details]
> build.log (sam, successful build)

I lied, it wasn't a successful build at all, I'm sorry -- I'd checked with ebuild and compared qith equery f, I have no idea why.
Comment 12 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 03:58:02 UTC
Sorry for the confusion. I *can* reproduce it on jiji

(mgorny: feel free to try it on jiji:
# machinectl shell arm64-stable
# emerge -v1 compiler-rt)
Comment 13 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 04:06:06 UTC
(In reply to Sam James from comment #12)
> Sorry for the confusion. I *can* reproduce it on jiji
> 
> (mgorny: feel free to try it on jiji:
> # machinectl shell arm64-stable
> # emerge -v1 compiler-rt)

If I go back, 14.0.4 doesn't work for me anymore either. But I'm pretty sure it did in the past (like when i saw the equery f earlier?)
Comment 14 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 04:06:40 UTC
(In reply to Sam James from comment #13)
> (In reply to Sam James from comment #12)
> > Sorry for the confusion. I *can* reproduce it on jiji
> > 
> > (mgorny: feel free to try it on jiji:
> > # machinectl shell arm64-stable
> > # emerge -v1 compiler-rt)
> 
> If I go back, 14.0.4 doesn't work for me anymore either. But I'm pretty sure
> it did in the past (like when i saw the equery f earlier?)

13.0.1 does work.
Comment 15 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 04:12:32 UTC
I don't yet get why but if I drop -nostartfiles, it works (i.e. revert 828d8bf14cac680b319b107412d1eda05661436f).

commit 828d8bf14cac680b319b107412d1eda05661436f
Author: Andreas K. Hüttel <dilfridge@gentoo.org>
Date:   Wed Jul 20 21:22:10 2022 +0000

    sys-libs/compiler-rt: add -nostartfiles to nolib_flags

    This avoids bootstrapping failures during e.g. pure LLVM stage builds
    as compiler-rt is checking for a working compiler but without -nostartfiles,
    is actually checking for a working compiler-rt too (which isn't yet installed!)

    See https://archives.gentoo.org/gentoo-releng-autobuilds/message/eaafa503472438245449f93c2bb64578:
    ```
    : && /usr/lib/llvm/14/bin/clang -O2 -pipe -nodefaultlibs -lc CMakeFiles/cmTC_77c36.dir/testCCompiler.c.o -o cmTC_77c36 && :
    ld.lld: error: cannot open crtbeginS.o: No such file or directory
    ld.lld: error: cannot open crtendS.o: No such file or directory
    clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
    ```

    Signed-off-by: Sam James <sam@gentoo.org>
Comment 16 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 04:17:46 UTC
(In reply to Sam James from comment #15)
> I don't yet get why but if I drop -nostartfiles, it works (i.e. revert
> 828d8bf14cac680b319b107412d1eda05661436f).
> 

Maybe we can change the logic to be:
- if USE=clang, do not touch LDFLAGS yet, and force clang usage (as it is now, but change the elif -> if)
- if compiler test fails regardless of USE=clang, try again with nolib_flags
with -nodefaultlibs -lc
- if *that* fails, try again with -nodefaultlibs -nostartfiles -lc

Right now, I think we're prematurely always using -nostartfiles even when it's not an issue, and apparently that breaks things.

As for *WHY*, my guess is -nostartfiles triggers something that means we only build for targets (?) and the ebuild only has -DCAN_TARGET_x86_64 & -DCAN_TARGET_i386. So we might want to see if we need options like that for other arches.
Comment 17 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 07:06:03 UTC
commit 755d296048de0477d2608299f6e5f9dcb5ec1af4
Author: Michał Górny <mgorny@gentoo.org>
Date:   Mon Aug 1 07:59:29 2022 +0200

    sys-libs/compiler-rt: Try the runtimes build for 15.x

    Signed-off-by: Michał Górny <mgorny@gentoo.org>
Comment 18 tt_1 2022-08-01 07:38:21 UTC
Do I have to bootstrap the whole 15.x toolchain to test the fix? 

Or may I locally backport the patch to the 14.0.6 ebuild instead?
Comment 19 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 07:40:15 UTC
(In reply to tt_1 from comment #18)
> Do I have to bootstrap the whole 15.x toolchain to test the fix? 
> 
> Or may I locally backport the patch to the 14.0.6 ebuild instead?

We're still talking about it, it's just a relevant change wrt the bug. I have not tried backporting the runtime stuff.

Did build for me with whole 15.x stuff.

I'll see about a workaround for 14.x later obviously.
Comment 20 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-01 07:41:36 UTC
Actually, I'd assumed it'd be more work, you might be able to make it work with 14.x with a runtime build trivially...
Comment 21 tt_1 2022-08-03 06:34:44 UTC
hey there, I tried =compiler-rt-14.0.6-r1 and can confirm its working with USE="+clang" on a native compiler, also USE="-clang" is working. 


USE="-clang" on cross compile not working (not sure if desireable?)
Comment 22 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-03 06:42:00 UTC
(In reply to tt_1 from comment #21)
> hey there, I tried =compiler-rt-14.0.6-r1 and can confirm its working with
> USE="+clang" on a native compiler, also USE="-clang" is working. 
> 
> 
> USE="-clang" on cross compile not working (not sure if desireable?)

I didn't mean to commit -r1 yet but really glad you tried it, could you show me what happens w -clang and cross? The *hope* is the "runtimes" stuff handles all the workarounds for us but I'm not sure if I believe in it yet
Comment 23 tt_1 2022-08-03 06:49:56 UTC
Created attachment 797116 [details]
compressed build log from aarch64-cross

I really don't know whats going on behind the scenes with regard to cross, have a look at the build log maybe?
Comment 24 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-03 23:28:31 UTC
(In reply to tt_1 from comment #23)
> Created attachment 797116 [details]
> compressed build log from aarch64-cross
> 
> I really don't know whats going on behind the scenes with regard to cross,
> have a look at the build log maybe?

Oh dear. It fails in the worst possible way, too (installing nothing).

Okay, first, let me revert the -nostartfiles change from before, so we're not broken anymore for !amd64, and we go from there.
Comment 25 Larry the Git Cow gentoo-dev 2022-08-03 23:33:18 UTC
The bug has been referenced in the following commit(s):

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

commit dc072af65039e77a4ecc35ffee42b0a29523d122
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-08-03 23:32:44 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-08-03 23:33:08 +0000

    sys-libs/compiler-rt: try better workaround for -nostartfiles
    
    Fix no installed files on !amd64.
    
    Bug: https://bugs.gentoo.org/862540
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild | 150 ++++++++++++++++++++++
 1 file changed, 150 insertions(+)
Comment 26 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-03 23:33:41 UTC
I'll sync 15.x 9999 depending on how this one goes.
Comment 27 tt_1 2022-08-04 14:21:24 UTC
ok, so recent changes commited for -r1 enable the native compile, regardless of clang useflag

cross-compile still broken, as expected
Comment 28 Larry the Git Cow gentoo-dev 2022-08-24 04:56:58 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8bb13b19b42601b8b57c5b1c2d64d1b0a04fede5

commit 8bb13b19b42601b8b57c5b1c2d64d1b0a04fede5
Author:     Alexander Miller <alex.miller@gmx.de>
AuthorDate: 2022-08-06 23:22:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-08-24 04:56:27 +0000

    sys-libs/compiler-rt: Override start symbol when adding -nostartfiles to LDFLAGS
    
    Trying to link executables for the configure checks generates linker
    warnings (in the CMake logs) like: "warning: cannot find entry symbol
    _start; defaulting to 0000000000001000".
    Moreover, with flags like -flto or -Wl,--gc-sections, the linker can
    discard all code, rendering the checks useless.
    
    Set main as entry symbol when linking with -nostartfiles to avoid
    both issues. (Note that the binaries would still crash, but that
    doesn't matter since they are never executed.)
    
    Bug: https://bugs.gentoo.org/862540
    Closes: https://bugs.gentoo.org/862798
    Signed-off-by: Alexander Miller <alex.miller@gmx.de>
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Comment 29 Larry the Git Cow gentoo-dev 2022-08-24 04:59:10 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7b05d4a0ac1d854afa97048fa1fe166d0e123d61

commit 7b05d4a0ac1d854afa97048fa1fe166d0e123d61
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-08-24 04:58:55 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-08-24 04:58:55 +0000

    sys-libs/compiler-rt: forward port nostartfiles fix
    
    Bug: https://bugs.gentoo.org/862540
    Bug: https://bugs.gentoo.org/862798
    See: 8bb13b19b42601b8b57c5b1c2d64d1b0a04fede5
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-libs/compiler-rt/compiler-rt-14.0.6-r1.ebuild   | 1 +
 sys-libs/compiler-rt/compiler-rt-15.0.0.9999.ebuild | 6 ++++--
 sys-libs/compiler-rt/compiler-rt-15.0.0_rc2.ebuild  | 6 ++++--
 sys-libs/compiler-rt/compiler-rt-16.0.0.9999.ebuild | 6 ++++--
 4 files changed, 13 insertions(+), 6 deletions(-)