From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 67E5015800D for ; Wed, 12 Jul 2023 03:30:50 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A12C3E07EC; Wed, 12 Jul 2023 03:30:49 +0000 (UTC) Received: from out-26.mta0.migadu.com (out-26.mta0.migadu.com [91.218.175.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8288CE07EC for ; Wed, 12 Jul 2023 03:30:48 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catcream.org; s=key1; t=1689132647; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3ZHs+IK4lA24aYYvd8PosEOfmwd/wsHWQaDGB2LLPxE=; b=msySqmBNXz4zz40QJ7eu34wNheK67vcNGG1NnLwG9jNNIf1eCHDVjpk53uTmXH8PqcD4mJ QV7UdAQoLpIhetHVqMriUvVAmZGCdpkLcCwiWLCjpPiZ4q32XdgVF5QkQ03zQu3ZQk1Ojl GJfek5T1l9GwQUDZPq8c/QkdKW0wbsAeJ/iiuZk6hoq7caWZaQNXKSScYnOhSn5ZEgS/LP oV1NHh9e82lwvScJKR3+CKEi4gI8tDiTa2INC+GTWgFlRejnNpj7qCqJDVMCUPcztrTx6g 5DBABeG7W2pYUf9UX9WRSthPR0PhRRXk+EnSvtsY7L6Rsuh4Wft1iTVxAs03UA== From: catcream To: gentoo-soc@lists.gentoo.org Subject: [gentoo-soc] Weekly report 6, LLVM libc Date: Wed, 12 Jul 2023 04:42:51 +0200 Message-ID: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-soc@lists.gentoo.org Reply-to: gentoo-soc@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT X-Archives-Salt: 918e2408-44b3-49c7-a12c-c55a0ca6b49a X-Archives-Hash: 605d852b6931f89fc67bc5ef814ae9eb =2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi! This week I have been working on LLVM/Clang support for Crossdev. This is currently done by swapping out the different Crossdev stages for ones that make sense for LLVM. Currently it replaces stage0 with checking whether LLVM can target the target triple's architecture by checking the LLVM_TARGETS USE-flag. Stage1, which normally installs libc headers and compiles a -stage1 C compiler is replaced by installing libc headers and compiling compiler-rt. Stage2 (kernel headers), is the same. Stage3 (libc install), is the same. Stage4, which compiles a full compiler is skipped completely. Another needed change was to make the compiler-rt ebuild cross-aware, with changes like making the assembler and C compiler target the target tri= ple, and including headers from the crossdev /usr/${CTARGET}/usr/include directory instead of using the host's libc headers. I got some help from wikky here, thanks! Currently doing 'crossdev --llvm -t riscv64-gentoo-linux-musl && riscv64-gentoo-linux-musl-emerge dash' produces a working binary that can be run using qemu-user like this 'qemu-riscv64 -L /usr/riscv64-gentoo-linux-musl /usr/riscv64-gentoo-linux-musl/bin/dash' which I think is very cool! However, there is still some issues with dynamically linking libraries built with the cross compiler. For example xz-utils installs liblzma.so which fails with "exec format error". (http://sprunge.us/HkSmms). I am currently looking into that. Another thing I'm still a little uncertain about is where to put all environment variables and compilation options, whether it's crossdev's job or the ebuilds'. This is something I will come back to, and I have some changes locally on my computer Crossdev patches: https://github.com/alfredfo/crossdev/commit/ec65dee4b4c359bf3e0fc374d31e05b= 147fa3f0d Compiler-rt patches: https://github.com/alfredfo/catcream_repo/blob/master/sys-libs/compiler-rt/= compiler-rt-17.0.0.9999.ebuild Later during the week I made ebuilds for LLVM libc and libc-hdrgen (generates LLVM libc headers from TableGen specification files). Normally you build LLVM libc together with libc-hdrgen, but when cross compiling it's a better idea to split these and keep libc-hdrgen a tool installed on the build host. I have played with only building libc headers for bootstrapping with crossdev but I haven't figured it all o= ut yet. To only install headers you can use the install-libc-headers target, but it seems like CMake still wants to build things. There's also the scudo allocator that needs to be statically linked to LLVM libc. My idea is to make a USE=3Dstatic-scudo flag for compiler-rt that gets set in crossdev when compiling compiler-rt for a LLVM libc target. These are also kept locally until I've figured out how to cross compile in stages. Many "small random issues" and technicalities have also poped up during this week that've taken quite a long time, but are not really worth digging into here. Next week I will continue with this until I can use it to work on LLVM libc, worst case scenario I could temporarily make a "franken LLVM libc ebu= ild" that does everything (headers, compiler-rt, scudo, llvm libc) in one shot, but it should definitely be possible to do it separately. I also forgot to update my llvm-common changes with the new elisp-site-file-install function that was inspired by my PR :( ... will fix that tomorrow. Thanks for reading! =2D --=20 catcream =2D----BEGIN PGP SIGNATURE----- iIcEARYIAC8WIQTrvBqrbtsVNc2oScop9g9HYPvztAUCZK4eYxEcY2F0QGNhdGNy ZWFtLm9yZwAKCRAp9g9HYPvztAzmAPsG63bzzcD3iZA+hTTiH954Z0fAmpwwOlU/ 4MzZmtQGogEAy0YQeviSMoSLearucY3gXNfYDG6ZdcmqB4QYmix8Igs=3D =3DeTPW =2D----END PGP SIGNATURE-----