Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How do I get an Ada Compiler on a Musl System? [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
ktoupt
n00b
n00b


Joined: 20 May 2023
Posts: 4

PostPosted: Sat May 20, 2023 1:28 pm    Post subject: How do I get an Ada Compiler on a Musl System? [Solved] Reply with quote

Edit: I was able to get sys-devel/gcc[ada] compiler. See my post later in this same thread on "Mon May 06, 2024 6:24 pm" for what I did.

Begin

Hi. I am going to be installing a new system soon, and I decided to try Musl
this time. First, I am checking viability on a VM.

One of my requirements is an Ada compiler for GHDL, but I am struggling getting
one installed. I first tried "natively" compiling `gnat-gpl`, cross compiling
it, and getting an Ada cross compiler.


First Attempt: `gnat-gpl` Natively

In the Musl VM:

Code:

# emerge -1a gnat-gpl

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

Calculating dependencies... done!
Dependency resolution took 2.10 s.

[ebuild  N     ] dev-lang/gnat-gpl-2021-r4  USE="ada bootstrap cxx fortran nls nptl openmp pie sanitize ssp -cet -d -debug -default-stack-clash-protection -default-znow -doc (-fixed-point) (-go) -graphite -hardened (-jit) -libssp (-lto) -modula2 (-multilib) -objc -objc++ -objc-gc (-pch) -pgo -rust -systemtap -test -vanilla -vtv -zstd

[...]
/var/tmp/portage/dev-lang/gnat-gpl-2021-r4/temp/environment: line 496: /var/tmp/portage/dev-lang/gnat-gpl-2021-r4/work/gnat-gpl-2014-x86_64-linux-bin/bin/gcc: No such file or directory
[...]


The error is very weird because the file exists. However, I expected this to
fail anyway since the Ada compiler depends on an Ada compiler, so
`dev-lang/gnat-gpl[bootstrap]` uses binaries to bootstrap, and the binaries
were probably not built for Musl. Checking with `objdump`, it does show that,
indeed, `glibc` is required.


Second Attempt: Cross Compiling `gnat-gpl`

Okay... Maybe I can cross compile `gnat-gpl`?

Code:

# crossdev -t x86_64-gentoo-linux-musl
[...]
# ARCH=amd64 PORTAGE_CONFIGROOT=/usr/x86_64-gentoo-linux-musl eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/17.1 (stable)
  [2]   default/linux/amd64/17.1/selinux (stable)
  [3]   default/linux/amd64/17.1/hardened (stable)
  [4]   default/linux/amd64/17.1/hardened/selinux (stable)
  [5]   default/linux/amd64/17.1/desktop (stable)
  [6]   default/linux/amd64/17.1/desktop/gnome (stable)
  [7]   default/linux/amd64/17.1/desktop/gnome/systemd (stable)
  [8]   default/linux/amd64/17.1/desktop/gnome/systemd/merged-usr (stable)
  [9]   default/linux/amd64/17.1/desktop/plasma (stable)
  [10]  default/linux/amd64/17.1/desktop/plasma/systemd (stable)
  [11]  default/linux/amd64/17.1/desktop/plasma/systemd/merged-usr (stable)
  [12]  default/linux/amd64/17.1/desktop/systemd (stable)
  [13]  default/linux/amd64/17.1/desktop/systemd/merged-usr (stable)
  [14]  default/linux/amd64/17.1/developer (exp)
  [15]  default/linux/amd64/17.1/no-multilib (stable)
  [16]  default/linux/amd64/17.1/no-multilib/hardened (stable)
  [17]  default/linux/amd64/17.1/no-multilib/hardened/selinux (stable)
  [18]  default/linux/amd64/17.1/no-multilib/systemd (dev)
  [19]  default/linux/amd64/17.1/no-multilib/systemd/merged-usr (dev)
  [20]  default/linux/amd64/17.1/no-multilib/systemd/selinux (exp)
  [21]  default/linux/amd64/17.1/no-multilib/systemd/selinux/merged-usr (exp)
  [22]  default/linux/amd64/17.1/systemd (stable)
  [23]  default/linux/amd64/17.1/systemd/merged-usr (stable)
  [24]  default/linux/amd64/17.1/systemd/selinux (exp)
  [25]  default/linux/amd64/17.1/systemd/selinux/merged-usr (exp)
  [26]  default/linux/amd64/17.1/clang (exp)
  [27]  default/linux/amd64/17.1/systemd/clang (exp)
  [28]  default/linux/amd64/17.1/systemd/clang/merged-usr (exp)
  [29]  default/linux/amd64/17.0/x32 (dev)
  [30]  default/linux/amd64/17.0/x32/systemd (exp)
  [31]  default/linux/amd64/17.0/x32/systemd/merged-usr (exp)
  [32]  default/linux/amd64/17.0/musl (dev)
  [33]  default/linux/amd64/17.0/musl/clang (exp)
  [34]  default/linux/amd64/17.0/musl/hardened (exp)
  [35]  default/linux/amd64/17.0/musl/hardened/selinux (exp)
# ARCH=amd64 PORTAGE_CONFIGROOT=/usr/x86_64-gentoo-linux-musl eselect profile set 32
# x86_64-gentoo-linux-musl-emerge -1a gnat-gpl

 * IMPORTANT: 4 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.


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

Calculating dependencies... done!
Dependency resolution took 1.76 s.

[ebuild  N     ] virtual/libintl-0-r2 to /usr/x86_64-gentoo-linux-musl/
[ebuild  N     ] virtual/libiconv-0-r2 to /usr/x86_64-gentoo-linux-musl/
[ebuild  N     ] sys-apps/findutils-4.9.0-r2 to /usr/x86_64-gentoo-linux-musl/ USE="nls (-selinux) -static -test -verify-sig"
[ebuild  N     ] dev-libs/gmp-6.2.1-r5 to /usr/x86_64-gentoo-linux-musl/ USE="asm cpudetection cxx -doc -pic -static-libs"
[ebuild  N     ] sys-libs/zlib-1.2.13-r1 to /usr/x86_64-gentoo-linux-musl/ USE="(split-usr) -minizip -static-libs -verify-sig"
[ebuild  N     ] dev-libs/mpfr-4.2.0_p9 to /usr/x86_64-gentoo-linux-musl/ USE="-static-libs -verify-sig"
[ebuild  N     ] sys-apps/gentoo-functions-0.19 to /usr/x86_64-gentoo-linux-musl/
[ebuild  N     ] dev-libs/mpc-1.3.1 to /usr/x86_64-gentoo-linux-musl/ USE="-static-libs"
[ebuild  N     ] sys-devel/gcc-config-2.11 to /usr/x86_64-gentoo-linux-musl/ USE="(cc-wrappers) (native-symlinks)"
[ebuild  N     ] sys-libs/musl-1.2.4 to /usr/x86_64-gentoo-linux-musl/ USE="(split-usr) -crypt -headers-only -verify-sig"
[ebuild  N     ] sys-libs/libxcrypt-4.4.33 to /usr/x86_64-gentoo-linux-musl/ USE="compat (split-usr) system -headers-only -static-libs -test"
[ebuild  N     ] virtual/libcrypt-2-r1 to /usr/x86_64-gentoo-linux-musl/ USE="-static-libs"
[ebuild  N     ] dev-lang/gnat-gpl-2021-r4 to /usr/x86_64-gentoo-linux-musl/ USE="ada bootstrap cxx fortran nls nptl openmp pie sanitize ssp -cet -d -debug -default-stack-clash-protection -default-znow -doc (-fixed-point) (-go) -graphite -hardened (-jit) -libssp (-lto) -modula2 (-multilib) -objc -objc++ -objc-gc (-pch) -pgo -rust -systemtap -test -vanilla -vtv -zstd"

[...]


Everything seems to have compiled fine until `dev-lang/gnat-gpl`:

Code:

[...]
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations.  Source code for these libraries can be found at
their respective hosting sites as well as at
https://gcc.gnu.org/pub/gcc/infrastructure/.  See also
http://gcc.gnu.org/install/prerequisites.html for additional info.  If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files.  They may be located in separate packages.
[...]


Not sure what to do about this...


Third Attempt: Ada Cross Compiler

Okay... Maybe I do not really need an Ada compiler on the target system. Maybe
I can just cross-compile one package (GHDL) as required. My host system has
`sys-devel/gcc[ada]`, so it should be no problem to build the cross compiler:

Code:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/13/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-13.1.0-r1/work/gcc-13.1.0/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/13/include/g++-v13 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/13/python --enable-objc-gc --enable-languages=c,c++,d,go,objc,obj-c++,fortran,ada,m2 --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 13.1.0-r1 p1' --with-gcc-major-version-only --enable-esp --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --enable-cet --disable-systemtap --disable-valgrind-annotations --enable-vtable-verify --with-zstd --with-isl --disable-isl-version-check --enable-default-pie --enable-default-ssp --with-build-config='bootstrap-lto bootstrap-cet'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.1.0 (Gentoo Hardened 13.1.0-r1 p1)


I added the `ada` use flag to `cross-x86_64-gentoo-linux-musl/gcc` in
`/etc/portage/package.use/cross-x86_64-gentoo-linux-musl`, and now it is time
to rebuild the cross compiler:

Code:

# emerge -1a cross-x86_64-gentoo-linux-musl/gcc


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

Calculating dependencies... done!
Dependency resolution took 6.78 s.

[ebuild   R    ] cross-x86_64-gentoo-linux-musl/gcc-13.1.1_p20230513  USE="ada*"

[...]
adaint.h:324:8: error: unknown type name ‘cpu_set_t’
[...]


Again, another error I do not know what to do about...

Looking at the `info` for `cross-x86_64-gentoo-linux-musl/gcc`, I just
realized I have `ADA_TARGET=gcc_any`, which is not part of the normal
`ada.eclass`. It is just a target I added by copying the `ada.eclass` to a
local repository and making it so it only depends on `sys-devel/gcc[ada]`
instead of a specific version. This is because the normally available targets
is for stable `gcc`, but I am using `~amd64`, so using the `gcc_12` target for
example would end up with me having both `gcc` 12 and 13 installed on my
system. Anyway, I do not think it would affect my ability to build a cross
compiler since, as far as I know, the `ADA_TARGET` environment variable is not
used when compiling `gcc`.


End

By the way, I do have `build.log`, `environment`, and `info` available for all
the failed builds, but I am not sure how to attach things in this forum, and I
do not see anything in
<https://wiki.gentoo.org/wiki/Project:Forums/Forum_guide>. (How do I attach?
Should I "zip" the files?) The files total 10532905 bytes, mostly due to
`cross-x86_64-gentoo-linux-musl/gcc` `build.log` (10048649 bytes).

Does anyone have any clues on getting an Ada compiler on Musl? I guess I could
use Podman or Docker for GHDL... Maybe I should just install a `glibc` system
since I do not really need Musl...

--- Edit by NeddySeagoon ---

Here is a paste of the above mentioned logs: <http://sprunge.us/bjU30b>
Search for '^\$ cat' to get to each file.
'native-bootstrap-*' files refer to the first attempt.
'cross-bootstrap-*' files refer to the second attempt.
'host-cross-ada-*' files refer to the third attempt.

The above was posted as a reply, taking the original post out of the "Unanswered Posts" search.
This is the only way to merge two posts. I've deleted the reply.


Last edited by ktoupt on Mon May 06, 2024 6:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54361
Location: 56N 3W

PostPosted: Sat May 20, 2023 7:20 pm    Post subject: Reply with quote

ktoupt,

I can reproduce your problem and tell why it happens but I don't have a fix.
The configure problem is ...

Code:
configure:5880: checking for the correct version of the gmp/mpfr/mpc libraries
configure:5911: /usr/x86_64-gentoo-linux-musl/tmp/portage/dev-lang/gnat-gpl-2021-r4/work/gnat-gpl-2014-x86_64-linux-bin/bin/gcc -o conftest -fno-lto -O2   -Wl,-O1 -Wl,--as-needed conftest.c  -lmpc -lmpfr -lgmp >&5
/usr/x86_64-gentoo-linux-musl/tmp/portage/dev-lang/gnat-gpl-2021-r4/work/gnat-gpl-2014-x86_64-linux-bin/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.7.4/ld: warning: library search path "/lib/../lib64" is unsafe for cross-compilation
/usr/x86_64-gentoo-linux-musl/tmp/portage/dev-lang/gnat-gpl-2021-r4/work/gnat-gpl-2014-x86_64-linux-bin/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.7.4/ld: warning: libm.so.6, needed by /usr/lib/../lib64/libmpc.so, not found (try using -rpath or -rpath-link)
/usr/x86_64-gentoo-linux-musl/tmp/portage/dev-lang/gnat-gpl-2021-r4/work/gnat-gpl-2014-x86_64-linux-bin/bin/../libexec/gcc/x86_64-pc-linux-gnu/4.7.4/ld: /usr/lib/../lib64/libmpc.so: undefined reference to `sqrt@GLIBC_2.2.5'
collect2: error: ld returned 1 exit status
configure:5911: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define LT_OBJDIR ".libs/"
| /* end confdefs.h.  */
| #include <mpc.h>
| int
| main ()
| {
|
|     mpfr_t n;
|     mpfr_t x;
|     mpc_t c;
|     int t;
|     mpfr_init (n);
|     mpfr_init (x);
|     mpfr_atan2 (n, n, x, MPFR_RNDN);
|     mpfr_erfc (n, x, MPFR_RNDN);
|     mpfr_subnormalize (x, t, MPFR_RNDN);
|     mpfr_clear(n);
|     mpfr_clear(x);
|     mpc_init2 (c, 53);
|     mpc_set_ui_ui (c, 1, 1, MPC_RNDNN);
|     mpc_cosh (c, c, MPC_RNDNN);
|     mpc_pow (c, c, c, MPC_RNDNN);
|     mpc_acosh (c, c, MPC_RNDNN);
|     mpc_clear (c);
|
|   ;
|   return 0;
| }
configure:5915: result: no
configure:5928: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.


Bootstrapping gnat-gpl requires and existing gnat-gpl so
Code:
x86_64-gentoo-linux-musl-emerge gnat-gpl
downloads one - but its been linked against glibc, not musl, so config checks fail.
Code:
Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
is the first such error.

You need a musl gnat-gpl to bootstrap musl gnat-gpl

Its been done once. There may be some guidance in that PR.

Beware the tuple
Code:
x86_64-gentoo-linux-musl
as its non-standard.
It won't matter for binaries that you build but the rest of the world will use
Code:
x86_64-unknown-linux-musl
.
The gentoo/unknown is not used for anything but is is checked for consistency.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
ktoupt
n00b
n00b


Joined: 20 May 2023
Posts: 4

PostPosted: Sat May 20, 2023 8:24 pm    Post subject: Reply with quote

NeddySeagoon wrote:
Bootstrapping gnat-gpl requires and existing gnat-gpl so
Code:
x86_64-gentoo-linux-musl-emerge gnat-gpl
downloads one - but its been linked against glibc, not musl, so config checks fail.
Code:
Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.
is the first such error.

You need a musl gnat-gpl to bootstrap musl gnat-gpl


That is what I figured was happening in the first and, I guess, second attempts mentioned in the original post. But I am still not sure why the cross compiler (cross-x86_64-gentoo-linux-musl/gcc) would not build with Ada enabled. Also, `crossdev -h` has a flag `--ex-gcc` which mentions `ada`, so I thought it would be easy, but I guess Musl was not tested. Oh, and the reason I am not using that flag is because I am not sure how it is supposed to be used. That is why I just put the `ada` use flag manually.

NeddySeagoon wrote:
Its been done once. There may be some guidance in that PR.


Thanks for the link. I briefly looked into it, and it looks like Alpine Linux has some patches. I will look into them whenever I have time, and maybe then I will be able to at least cross compile Ada for Musl.

NeddySeagoon wrote:
Beware the tuple
Code:
x86_64-gentoo-linux-musl
as its non-standard.
It won't matter for binaries that you build but the rest of the world will use
Code:
x86_64-unknown-linux-musl
.
The gentoo/unknown is not used for anything but is is checked for consistency.


I never understood these tuples. I usually put `unknown` there (although I usually only cross compile for embedded), but the stage 3 archive has `CHOST` set to `x86_64-gentoo-linux-musl`, so that is what I used to be consistent. (Also, I just realized, my `glibc` install is `x86_64-pc-linux-gnu`).
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54361
Location: 56N 3W

PostPosted: Sat May 20, 2023 8:34 pm    Post subject: Reply with quote

ktoupt,

I collect cross toolchains.
Code:
$ ls /usr/*linux*  -d
/usr/aarch64-unknown-linux-gnu         /usr/powerpc-unknown-linux-gnu
/usr/armv5tel-softfloat-linux-gnueabi  /usr/x86_64-gentoo-linux-musl
/usr/i486-pc-linux-gnu                 /usr/x86_64-pc-linux-gnu
/usr/mips64el-unknown-linux-gnu


About the only one I use is aarch64-unknown-linux-gnu for Raspberry Pi 4.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
ktoupt
n00b
n00b


Joined: 20 May 2023
Posts: 4

PostPosted: Sun May 21, 2023 8:08 pm    Post subject: Reply with quote

I applied some patches from <https://git.alpinelinux.org/aports/tree/main/gcc?h=master> by copying them into `/etc/portage/patches/cross-x86_64-gentoo-linux-musl/gcc/`, and now I am getting the following error:

Code:
[...]
gnatbind -I../generated -I/usr/lib/gcc/x86_64-pc-linux-gnu/13/adalib/../adainclude -I/usr/lib/gcc/x86_64-pc-linux-gnu/13/adalib -I. -I/var/tmp/portage/cross-x86_64-gentoo-linux-musl/gcc-13.1.1_p20230520/work/gcc-13-20230520/gcc/ada -o b_gnatl.adb gnatlink.ali
error: "s-stalib.adb" must be recompiled ("s-parame.ads" has been modified)
error: "s-secsta.adb" must be recompiled ("s-parame.ads" has been modified)
error: "a-except.adb" must be recompiled ("s-parame.ads" has been modified)
error: "s-exctab.adb" must be recompiled ("s-parame.ads" has been modified)
error: "s-casuti.adb" must be recompiled ("s-parame.ads" has been modified)
error: "i-c.adb" must be recompiled ("s-parame.ads" has been modified)
error: "i-cstrin.adb" must be recompiled ("s-parame.ads" has been modified)
make[2]: *** [../gcc-interface/Makefile:878: b_gnatl.adb] Error 5
make[2]: Leaving directory '/var/tmp/portage/cross-x86_64-gentoo-linux-musl/gcc-13.1.1_p20230520/work/build/gcc/ada/tools'
make[2]: *** Waiting for unfinished jobs....
[...]


I think I will stop trying to get this to build for now.

If anyone is curious about the exact patches, I was on commit `5a7d9c04e9022eec5dac568ad5338ebf05150ea9`, and these were the patches I copied:
  • `0014-ada-fix-shared-linking.patch`
  • `0025-ada-libgnarl-compatibility-for-musl.patch`
  • `0026-ada-musl-support-fixes.patch`
  • `0032-libgnat-time_t-is-always-64-bit-on-musl-libc.patch`
Back to top
View user's profile Send private message
ktoupt
n00b
n00b


Joined: 20 May 2023
Posts: 4

PostPosted: Mon May 06, 2024 6:24 pm    Post subject: Reply with quote

I think I have successfully bootstrapped sys-devel/gcc[ada] on musl:

Code:
musl$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-musl/13/lto-wrapper
Target: x86_64-pc-linux-musl
Configured with: /var/tmp/portage/sys-devel/gcc-13.2.1_p20240503/work/gcc-13-20240503/configure --host=x86_64-pc-linux-musl --build=x86_64-pc-linux-musl --prefix=/usr --bindir=/usr/x86_64-pc-linux-musl/gcc-bin/13 --includedir=/usr/lib/gcc/x86_64-pc-linux-musl/13/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-musl/13 --mandir=/usr/share/gcc-data/x86_64-pc-linux-musl/13/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-musl/13/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-musl/13/include/g++-v13 --disable-silent-rules --disable-dependency-tracking --with-python-dir=/share/gcc-data/x86_64-pc-linux-musl/13/python --enable-languages=c,c++,fortran,ada --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --disable-nls --disable-libunwind-exceptions --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 13.2.1_p20240503 p15' --with-gcc-major-version-only --enable-libstdcxx-time --enable-lto --disable-libstdcxx-pch --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-multilib --with-multilib-list=m64 --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libssp --disable-libada --disable-systemtap --disable-valgrind-annotations --disable-vtable-verify --disable-libvtv --with-zstd --without-isl --enable-default-pie --enable-default-ssp --disable-fixincludes --with-build-config=bootstrap-lto
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.1 20240503 (Gentoo Hardened 13.2.1_p20240503 p15)

musl$ ghdl --version
GHDL 4.1.0 (tarball) [Dunoon edition]
 Compiled with GNAT Version: 13.2.1 20240503
 static elaboration, mcode JIT code generator
Written by Tristan Gingold.

Copyright (C) 2003 - 2024 Tristan Gingold.
GHDL is free software, covered by the GNU General Public License.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.




Here is how:

I do not know why crossdev causes weird errors (like the previous post) so I
tried creating cross compiler in a different way.


Anyway, first you need a glibc system with sys-devel/gcc[ada] (or
dev-lang/gnat-gpl). This can be, for example, a chroot.


Now, to build the cross compiler, I used musl-cross-make,
which I found mentioned in the getting started page of musl.

Code:
glibc$ cd
glibc$ git clone https://github.com/richfelker/musl-cross-make.git
glibc$ cd musl-cross-make
glibc$ echo "TARGET = x86_64-pc-linux-musl" >config.mak
glibc$ echo "GCC_VER = 13.2.0" >>config.mak
glibc$ echo "MUSL_VER = 1.2.4" >>config.mak
glibc$ echo "GCC_CONFIG += --enable-languages=c,c++,fortran,ada" >>config.mak
glibc$ echo "5f95b6d042fb37d45c6cbebfc91decfbc4fb493c  gcc-13.2.0.tar.xz" >hashes/gcc-13.2.0.tar.xz.sha1
glibc$ mkdir patches/gcc-13.2.0 # put the 4 patches mentioned in previous post from alpine in here
glibc$ make -j4


I think GCC_VER should not be lower than your host/build compiler.

This compiler can compile ada for musl from glibc.

Now install it somewhere... I did not feel like messing with environment
variables, so I just installed to /usr/local (I can just "rm -r" everything
in there later since I don't have anything else in there).

Code:
glibc# make OUTPUT=/usr/local install



Next step is to build the native compiler (for musl from musl). I did these
steps based on Linux From Scratch (I could not make it with musl-cross-make).
Download binutils, gcc, mpfr, gmp, and mpc source code (they are probably
already in musl-cross-make/sources). Note that "/musl_root" is literally the
root of the musl system. If the glibc is a chroot, then you can bind mount "/"
to "/musl_root" in the chroot before chroot. Compile the stuff:

Code:
glibc$ cd
glibc$ tar -xf binutils*
glibc$ cd binutils...
glibc$ sed '6009s/$add_dir//' -i ltmain.sh
glibc$ mkdir build
glibc$ cd build
glibc$ ../configure                     \
   --prefix=/usr/local             \
   --with-build-sysroot=/musl_root \
   --build=x86_64-pc-linux-gnu     \
   --host=x86_64-pc-linux-musl     \
   --disable-nls                   \
   --enable-shared                 \
   --enable-gprofng=no             \
   --disable-werror                \
   --enable-64-bit-bfd             \
   --enable-default-hash-style=gnu
glibc$ make -j4
glibc# make DESTDIR=/musl_root install

glibc$ cd
glibc$ tar -xf gcc*
glibc$ cd gcc...
glibc$ tar -xf ../mpfr-*
glibc$ mv -v mpfr-* mpfr
glibc$ tar -xf ../gmp-*
glibc$ mv -v gmp-* gmp
glibc$ tar -xf ../mpc-*
glibc$ mv -v mpc-* mpc
glibc$ git apply /path/to/the/four/patches/from/alpine/00*
glibc$ mkdir build
glibc$ cd build
glibc$ ../configure                     \
   --build=x86_64-pc-linux-gnu     \
   --host=x86_64-pc-linux-musl     \
   --target=x86_64-pc-linux-musl   \
   --prefix=/usr/local             \
   --with-build-sysroot=/musl_root \
   --enable-default-pie            \
   --enable-default-ssp            \
   --disable-nls                   \
   --disable-multilib              \
   --disable-libatomic             \
   --disable-libgomp               \
   --disable-libquadmath           \
   --disable-libsanitizer          \
   --disable-libssp                \
   --disable-libvtv                \
   --enable-languages=c,c++,fortran,ada
glibc$ make -j4


This compiler can compile ada for musl from musl.

Install it somewhere accessible from the musl system... Again, I did not feel
like messing with too many environment variables, so I just installed to
/usr/local

Code:
glibc# make DESTDIR=/musl_root install



(If you install somewhere else, I think you can temporarily set these
variables in make.conf: CC CPP CXX AR NM RANLIB GCC GNAT GNATBIND GNATMAKE
GNATLS GNATPREP GNATCHOP. And make sure the library paths are correct down
below...)


In musl, make sure you can use the previous compiler. If you installed in
/usr/local, then it should already be in your path, but there is still a need
to make sure the library path is correct:

Code:
musl# echo "/usr/local/lib/gcc/x86_64-pc-linux-musl/13.2.0/adalib" >/etc/ld.so.conf.d/01-TMP-DELETE-ME.conf
musl# echo "/usr/local/lib/gcc/x86_64-pc-linux-musl/13.2.0" >>/etc/ld.so.conf.d/01-TMP-DELETE-ME.conf
musl# echo "/usr/local/lib" >>/etc/ld.so.conf.d/01-TMP-DELETE-ME.conf
musl# ldconfig
Updating links is not implemented.



Add the four patches to /etc/portage/patches/sys-devel/gcc in the musl system.

Now you should be able to build sys-devel/gcc[ada] , but if you try directly,
then you will get a circular dependency. I could not figure out how to tell
portage to ignore that (I tried using the provides feature), so I copied the
gcc ebuild (and do not forget the files directory) and toolchain eclass to a
local repository, then, in the toolchain eclass, I removed the following three
lines:

Code:
if tc_has_feature ada ; then
   BDEPEND+=" ada? ( || ( sys-devel/gcc[ada] dev-lang/gnat-gpl[ada] ) )"
fi


Now build

Code:
musl# emerge -1a sys-devel/gcc # remember to enable ada use flag first!



Finally, you should clean up some stuff...

Code:
musl# rm -r /usr/local/*
musl# rm /etc/ld.so.conf.d/01-TMP-DELETE-ME.conf
musl# echo "/lib/gcc/x86_64-pc-linux-musl/13/adalib" >/etc/ld.so.conf.d/06-libgnat.conf
musl# ldconfig
Updating links is not implemented.


Remove sys-devel/gcc from local repo (and the toolchain eclass). And for good
measure, try rebuilding sys-devel/gcc, then sys-devel/binutils and
sys-libs/musl.

Also

Code:
glibc# rm-r /usr/local/*
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum