Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

crossdev with GCC+LLVM toolchains

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
viacheslavg
n00b
n00b
Posts: 27
Joined: Fri Sep 23, 2016 1:55 pm

crossdev with GCC+LLVM toolchains

  • Quote

Post by viacheslavg » Sun Feb 15, 2026 9:10 am

Hello,

Please, help me to understand following:

I have aarch64-unknown-linux-gnu crossdev env configured in according to https://wiki.gentoo.org/wiki/Crossdev. It uses GCC toolchain. Everything works fine here.

Additionally I have LLVM/clang on my system with LLVM_TARGETS="AArch64". So, my clang is capable of crosscompiling for aarch64. right?

As per documentation it is clear that I can't fully setup LLVM crossdev for "-gnu" with

Code: Select all

crossdev --llvm -t aarch64-unknown-linux-gnu
because glibc can't be compiled with clang.

Is it possible *on top* of my existing aarch64-unknown-linux-gnu env add support of clang cross compiling?

For example, if I try to crosscompile firefox with USE="clang" I have

Code: Select all

 0:00.95 checking for the target C compiler... not found
 0:00.95 DEBUG: _cc: Looking for aarch64-unknown-linux-gnu-clang-21
 0:00.95 ERROR: Cannot find the target C compiler
which is expected.

If I try to manually install clang-crossdev-wrappers (manually unmasking it), it provides respective symlinks but now I have

Code: Select all

 0:00.96 DEBUG: Executing: `/usr/lib/llvm/21/bin/aarch64-unknown-linux-gnu-clang-21 --sysroot /usr/aarch64-unknown-linux-gnu /var/tmp/portage/www-client/firefox-147.0.1/temp/conftest_rog1cao.c -E`
 0:00.96 DEBUG: The command returned non-zero exit status 1.
 0:00.96 DEBUG: Its error output was:
 0:00.96 DEBUG: | clang-21: error: configuration file '/etc/clang/cross/aarch64-unknown-linux-gnu.cfg' cannot be opened: No such file or directory
 0:00.96 ERROR: Command `/usr/lib/llvm/21/bin/aarch64-unknown-linux-gnu-clang-21 --sysroot /usr/aarch64-unknown-linux-gnu /var/tmp/portage/www-client/firefox-147.0.1/temp/conftest_rog1cao.c -E` failed with exit status 1.
i.e. I need some extra clang configuration for cross env.

Am I doing something nasty here? Is it possible to make clang crosscompile for aarch64 with glibc somewhow?

Thanks
Top
turtles
Veteran
Veteran
User avatar
Posts: 1713
Joined: Fri Dec 31, 2004 7:30 am

  • Quote

Post by turtles » Tue Feb 17, 2026 9:59 pm

Sort answer yes its Gentoo anything is possible. 3 observations;
  • Seems like you still need the target's headers and libraries, to get a functional glibc environment for AArch64 via crossdev I'd try:

    Code: Select all

    crossdev -s4 --target aarch64-unknown-linux-gnu
    The -s4 (Also build a full compiler) command I'd think builds a target environment using GCC.
  • Invoking Clang: Since Clang is a native cross-compiler (assuming LLVM_TARGETS="AArch64" is set in make.conf), you just need to point it to that new sysroot so it finds the right glibc:
    I'd make a test file (hello.c) and test it

    Code: Select all

    #include <stdio.h>
    
    int main() {
    printf("Hello from AArch64!\n");
    return 0;
    }
    

    Code: Select all

    clang --target=aarch64-unknown-linux-gnu --sysroot=/usr/aarch64-unknown-linux-gnu hello.c
  • To use aarch64-unknown-linux-gnu-emerge with Clang, I'd try some kind of a config at /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf:

    Code: Select all

    CC="clang --target=aarch64-unknown-linux-gnu"
    CXX="clang++ --target=aarch64-unknown-linux-gnu"
    If you already have one you might share it so others can look it over
Hope that helps, I am not a expert on crossdev but I use it.
Donate to Gentoo
Top
viacheslavg
n00b
n00b
Posts: 27
Joined: Fri Sep 23, 2016 1:55 pm

  • Quote

Post by viacheslavg » Wed Feb 18, 2026 6:48 pm

turtles, thanks for support.

Right, I have

Code: Select all

crossdev -s4 --target aarch64-unknown-linux-gnu
setup correctly. cross-compilation with gcc works fine.

This

Code: Select all

clang --target=aarch64-unknown-linux-gnu --sysroot=/usr/aarch64-unknown-linux-gnu hello.c
also works as expected. I have aarch64 binary output.

However firefox is not able to cross-compile. Errors are mentioned in the first post.

I also tried to put

Code: Select all

CC="clang --target=aarch64-unknown-linux-gnu"
CXX="clang++ --target=aarch64-unknown-linux-gnu"
in make.conf.
Still fails with:

Code: Select all

 0:05.39 checking for the target C compiler... not found
 0:05.39 DEBUG: _cc: Looking for aarch64-unknown-linux-gnu-clang-21
 0:05.39 ERROR: Cannot find the target C compiler
Does firefox supports cross-compilation at all? Maybe it is not supported? I can't find any info.

My make.conf looks like this

Code: Select all

# Note: profile variables are set/overridden in profile/ files:
# etc/portage/profile/use.force (overrides kernel_* USE variables)
# etc/portage/profile/make.defaults (overrides ARCH, KERNEL, ELIBC variables)

#CHOST=aarch64-unknown-linux-gnu
CBUILD=x86_64-pc-linux-gnu

ROOT=/usr/aarch64-unknown-linux-gnu/
PKGDIR=/usr/aarch64-unknown-linux-gnu/var/cache/binpkgs/
PORTAGE_TMPDIR=/var/tmp/

ACCEPT_KEYWORDS="~arm64"

COMMON_FLAGS="-O2 -pipe -fomit-frame-pointer -march=armv8-a+crc -mtune=cortex-a53"
CFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${COMMON_FLAGS}"
FCFLAGS="${COMMON_FLAGS}"
FFLAGS="${COMMON_FLAGS}"
CXXFLAGS="${CFLAGS}"

#CC="clang --target=aarch64-unknown-linux-gnu"
#CXX="clang++ --target=aarch64-unknown-linux-gnu"

MAKEOPTS="-j12"
EMERGE_DEFAULT_OPTS="--jobs=1 --load-average=4 --autounmask-write"

CPU_FLAGS_ARM="edsp neon thumb vfp vfpv3 vfpv4 vfp-d32 aes sha1 sha2 crc32 v4 v5 v6 v7 v8 thumb2"

VIDEO_CARDS="lima"

FEATURES="-collision-protect -pid-sandbox -network-sandbox sandbox"

FEATURES="${FEATURES} buildpkg"
BINPKG_FORMAT="gpkg"

FEATURES="${FEATURES} getbinpkg"
PORTAGE_BINHOST=""
PORTAGE_BINHOST="${PORTAGE_BINHOST} http://192.168.1.171/aarch64-packages"

USE="${ARCH} wayland gles2 gles2-only -opengl -vulkan -gnome -kde -jumbo-build -introspection -vala"

LLVM_TARGETS="AArch64"

ACCEPT_LICENSE="curl"

GENTOO_MIRRORS="http://gentoo.osuosl.org/ http://trumpetti.atm.tut.fi/gentoo/ http://distfiles.gentoo.org"
Top
Post Reply

3 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic