Skip to content

Commit

Permalink
Update to LLVM 16 and GCC 14
Browse files Browse the repository at this point in the history
  • Loading branch information
reznikmm authored and godunko committed Jun 27, 2024
1 parent 42ea37d commit cd0c10a
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 79 deletions.
8 changes: 4 additions & 4 deletions .copr/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

srpm:
mkdir /tmp/.copr
cp -v `dirname $(spec)`/../patches/gnat-llvm.patch /tmp/.copr
cp -v `dirname $(spec)`/../patches/*.patch /tmp/.copr
tar cavf /tmp/.copr/`grep ^Source0: $(spec)| sed -e 's/^.* //'` \
--exclude-vcs -C .. `basename $(realpath .)`
curl -L -o /tmp/.copr/gnat-llvm.zip https://github.com/AdaCore/gnat-llvm/archive/28c91e94c4227e6d9eabb2aeed4c0c12f6a4f3de.zip
curl -L -o /tmp/.copr/bb-runtimes.zip https://github.com/Fabien-Chouteau/bb-runtimes/archive/c1d089bd8880cec250266cf71d6a22cc74fdba79.zip
curl -L -o /tmp/.copr/gcc.zip https://github.com/gcc-mirror/gcc/archive/64d5610f44c995b88261bf83f53a200355cb530f.zip
curl -L -o /tmp/.copr/gnat-llvm.zip https://github.com/AdaCore/gnat-llvm/archive/66e36d929524972353600db5d604d0189cf0308f.zip
curl -L -o /tmp/.copr/bb-runtimes.zip https://github.com/Fabien-Chouteau/bb-runtimes/archive/e59080e0c4b49d12e00538595052dea2dceb5a6e.zip
curl -L -o /tmp/.copr/gcc.zip https://github.com/gcc-mirror/gcc/archive/cd0059a1976303638cea95f216de129334fc04d1.zip
rpmbuild -bs $(spec) --define="_sourcedir /tmp/.copr" --define="_srcrpmdir $(outdir)"
32 changes: 25 additions & 7 deletions .copr/adawebpack.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
%define __os_install_post %{nil}

Name: adawebpack
Version: 22.1.0
Version: 24.0.0
Release: git%{?dist}
Summary: Ada WASM Runtime and Bindings for Web API
Group: Development/Libraries
Expand All @@ -17,15 +17,16 @@ Source1: gnat-llvm.zip
Source2: bb-runtimes.zip
Source3: gcc.zip
Patch0: gnat-llvm.patch
Patch1: llvm_wrapper2.patch
BuildRequires: bsdtar
BuildRequires: gcc-gnat
BuildRequires: fedora-gnat-project-common >= 3
BuildRequires: gprbuild
BuildRequires: gcc-c++
BuildRequires: libstdc++-static
BuildRequires: lld
BuildRequires: llvm-devel >= 14
BuildRequires: clang
BuildRequires: llvm16-devel
BuildRequires: clang16-devel
BuildRequires: chrpath

# gprbuild only available on these:
Expand All @@ -35,29 +36,41 @@ ExclusiveArch: %GPRbuild_arches
Ada WASM Runtime and Bindings for Web API

%prep
%setup -T -b1 -a 0 -a 2 -n gnat-llvm-28c91e94c4227e6d9eabb2aeed4c0c12f6a4f3de/
%setup -T -b1 -a 0 -a 2 -n gnat-llvm-66e36d929524972353600db5d604d0189cf0308f/
#export LANG=C.utf8
LANG=C.utf8 bsdtar -x -f %{S:3} gcc-*/gcc/ada
mv -v gcc-*/gcc/ada llvm-interface/gnat_src
mv %{name} llvm-interface/%{name}_src
mv -v bb-runtimes-*/gnat_rts_sources/include/rts-sources llvm-interface/
ln -s %{name}_src/source/rtl/Makefile.target llvm-interface/
%patch0 -p0
%patch 0 -p0
%patch 1 -p0


%build
for J in /usr/bin/{llvm-config,opt,llvm-dis,llvm-ranlib}-16; do ln -v -s $J `basename $J -16`; done
export PATH=$PWD:$PATH

ln -s /usr/lib64/llvm16/lib/libclang-cpp.so ./libclangBasic.so

export LIBRARY_PATH=$PWD

make -C llvm-interface/ wasm
PATH=$PATH:`pwd`/llvm-interface/bin make -C llvm-interface/%{name}_src GPRBUILD_FLAGS=--db\ `pwd`/llvm-interface/%{name}_src/packages/Fedora
rm -v -f llvm-config opt llvm-dis llvm-ranlib
for J in /usr/bin/*-16; do ln -v -s $J `basename $J -16`; done
PATH=`pwd`/llvm-interface/bin:$PATH make -C llvm-interface/%{name}_src GPRBUILD_FLAGS=--db\ `pwd`/llvm-interface/%{name}_src/packages/Fedora

%install
cd llvm-interface
chrpath -d bin/*
find -D exec bin -size +100k -exec chrpath -d {} \;
mkdir -p %{buildroot}/usr/share/gprconfig
mkdir -p %{buildroot}/usr/lib/gnat
mkdir -p %{buildroot}/usr/share/%{name}
cp %{name}_src/packages/Fedora/llvm.xml %{buildroot}/usr/share/gprconfig/
cp %{name}_src/gnat/%{name}_config.gpr %{buildroot}/usr/lib/gnat/
cp -r bin lib %{buildroot}/usr
cp -v %{name}_src/source/%{name}.mjs %{buildroot}/usr/share/%{name}/
cp -v %{name}_src/utilities/update-alternatives-clang.sh %{buildroot}/usr/share/%{name}/
PATH=$PATH:`pwd`/bin gprconfig --batch -o /tmp/llvm.cgpr --db `pwd`/%{name}_src/packages/Fedora --target=llvm --config=ada,,
PATH=$PATH:`pwd`/bin gprinstall --target=llvm --prefix=%{buildroot}/usr --project-subdir=%{buildroot}/usr/lib/gnat -P %{name}_src/gnat/%{name}.gpr -p --config=/tmp/llvm.cgpr

Expand All @@ -68,6 +81,7 @@ PATH=$PATH:`pwd`/bin gprinstall --target=llvm --prefix=%{buildroot}/usr --projec
%dir /usr/lib/rts-native
%dir /usr/lib/gnat
/usr/bin/llvm-*
/usr/bin/target.atp
/usr/include/%{name}/*.ad[sb]
/usr/lib/%{name}/*.{ali,o}
/usr/lib/rts-native/adainclude/*.ad[sb]
Expand All @@ -77,7 +91,11 @@ PATH=$PATH:`pwd`/bin gprinstall --target=llvm --prefix=%{buildroot}/usr --projec
/usr/lib/gnat/manifests/%{name}
/usr/share/gprconfig/llvm.xml
/usr/share/%{name}/%{name}.mjs
/usr/share/%{name}/update-alternatives-clang.sh

%changelog
* Thu Jun 27 2024 Maxim Reznik <reznikmm@gmail.com> - 24.0.0-git
- Update to LLVM 16 and GCC 14

* Fri Feb 21 2020 Maxim Reznik <reznikmm@gmail.com> - 0.1.0-git
- Initial package
28 changes: 14 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix: # Build debug and production
os: [ubuntu-20.04] # , windows-latest] # there is no LLD 14 in msys2 anymore
os: [ubuntu-22.04] # , windows-latest] # there is no LLD 14 in msys2 anymore
runs-on: ${{ matrix.os }}
steps:
- name: 'git config'
Expand All @@ -23,7 +23,7 @@ jobs:
if: ${{ runner.os != 'Windows' }}
with:
repository: AdaCore/gnat-llvm
ref: '28c91e94c4227e6d9eabb2aeed4c0c12f6a4f3de'
ref: '66e36d929524972353600db5d604d0189cf0308f'
path: gnat-llvm

- name: Get bb-runtimes
Expand All @@ -32,49 +32,49 @@ jobs:
with:
repository: Fabien-Chouteau/bb-runtimes
path: gnat-llvm/llvm-interface/bb-runtimes
ref: 'gnat-fsf-12'
ref: 'gnat-fsf-14'

- name: Get gcc
uses: actions/checkout@v2
if: ${{ runner.os != 'Windows' }}
with:
repository: gcc-mirror/gcc
path: gnat-llvm/llvm-interface/gcc
ref: '64d5610f44c995b88261bf83f53a200355cb530f'
ref: 'releases/gcc-14.1.0'

- name: Get AdaWebPack
uses: actions/checkout@v2
with:
path: gnat-llvm/llvm-interface/adawebpack_src

- name: Get GNAT toolchain with alire
uses: alire-project/setup-alire@v1
uses: alire-project/setup-alire@v3
if: ${{ runner.os != 'Windows' }}
with:
toolchain: gnat_native^12 gprbuild^22
toolchain_dir: ./cached_gnat
toolchain: gnat_native^14 gprbuild

- name: Fetch LLVM
if: ${{ runner.os != 'Windows' }}
run: |
URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0
curl -L $URL/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz \
URL=https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.4
curl -L $URL/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04.tar.xz \
| tar xJf -
- name: Build (Linux)
if: ${{ runner.os != 'Windows' }}
run: |
alr toolchain --select gnat_native^14 gprbuild
export PREFIX=$PWD/adawebpack
export PATH=$PWD/gnat-llvm/llvm-interface/bin:$PATH
export PATH=`ls -d $PWD/cached_gnat/*/bin |tr '\n' ':'`$PATH
export PATH=$PWD/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH
export PATH=`ls -d $HOME/.local/share/alire/toolchains/*/bin |tr '\n' ':'`$PATH
export PATH=$PWD/clang+llvm-16.0.4-x86_64-linux-gnu-ubuntu-22.04/bin:$PATH
echo PATH=$PATH
pwd
ls -l
ls -l gnat-llvm/llvm-interface/
cd gnat-llvm
patch -p0 < llvm-interface/adawebpack_src/patches/gnat-llvm.patch
cd llvm-interface
cd gnat-llvm/llvm-interface
patch -p1 < adawebpack_src/patches/gnat-llvm.patch
patch -p1 < adawebpack_src/patches/llvm_wrapper2.patch
ln -sv gcc/gcc/ada gnat_src
ln -sv adawebpack_src/source/rtl/Makefile.target
ln -sv bb-runtimes/gnat_rts_sources/include/rts-sources
Expand Down
51 changes: 22 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ Prebuild packages are available on [Release page](https://github.com/godunko/ada
You will also need `wasm-ld`, the Web asssembly linker. You will find this:

* on Fedora Linux through the `lld` package;
* on Ubuntu through the `lld-15` package;
* on Ubuntu through the `lld-16` package;
* on other Linux systems look for a similarly-named package.

## How to build

* Setup GNAT using [Alire](https://alire.ada.dev/) or GNAT Community 2021.
* Setup GNAT using [Alire](https://alire.ada.dev/).

* Clone [GNAT-LLVM](https://github.com/AdaCore/gnat-llvm). Latest known good revision of GNAT-LLVM compatible with GNAT FSF is `e000ea613704acc27238ec17ce020251427f9e1d`.
* Clone [GNAT-LLVM](https://github.com/AdaCore/gnat-llvm). Latest known good revision of GNAT-LLVM compatible with GNAT FSF is `66e36d929524972353600db5d604d0189cf0308f`.
```
git clone https://github.com/AdaCore/gnat-llvm
git -C gnat-llvm checkout e000ea613704acc27238ec17ce020251427f9e1d
git -C gnat-llvm checkout 66e36d929524972353600db5d604d0189cf0308f
```

* Clone [bb-runtimes](https://github.com/Fabien-Chouteau/bb-runtimes). Use `gnat-fsf-12` branch.
* Clone [bb-runtimes](https://github.com/Fabien-Chouteau/bb-runtimes). Use `gnat-fsf-14` branch.
```
git clone -b gnat-fsf-12 https://github.com/Fabien-Chouteau/bb-runtimes gnat-llvm/llvm-interface/bb-runtimes
git clone -b gnat-fsf-14 https://github.com/Fabien-Chouteau/bb-runtimes gnat-llvm/llvm-interface/bb-runtimes
```

* Clone [GCC](https://github.com/gcc-mirror/gcc) sources. Use, for instance, `e000ea613704acc27238ec17ce020251427f9e1d` commit.
* Clone [GCC](https://github.com/gcc-mirror/gcc) sources. Use, for instance, `releases/gcc-14.1.0` commit.
```
git clone --single-branch --shallow-since=13-11-2022 https://github.com/gcc-mirror/gcc gnat-llvm/llvm-interface/gcc
git -C gnat-llvm/llvm-interface/gcc checkout e000ea613704acc27238ec17ce020251427f9e1d
git clone --single-branch --branch=releases/gcc-14 --shallow-since=01-04-2024 https://github.com/gcc-mirror/gcc gnat-llvm/llvm-interface/gcc
git -C gnat-llvm/llvm-interface/gcc checkout releases/gcc-14.1.0
```

* Setup GNAT-LLVM development environment, see details in
Expand All @@ -43,14 +43,14 @@ You will also need `wasm-ld`, the Web asssembly linker. You will find this:
cmake ... -DLLVM_ENABLE_PROJECTS='...;clang;lld' -DLLVM_TARGETS_TO_BUILD="...;WebAssembly"
```

On Ubuntu it is possible to install prebuild LLVM/CLang packages (use LLVM/CLang 15). However,
On Ubuntu it is possible to install prebuild LLVM/CLang packages (use LLVM/CLang 16). However,
alternatives need to be updated using the provided script:

```
sudo utilities/update-alternatives-clang.sh 15 100
sudo utilities/update-alternatives-clang.sh 16 100
```

Or install a [LLVM 15 binary release](https://github.com/llvm/llvm-project/releases) (`llvm-15`, `lld-15` and `clang-15` are required).
Or install a [LLVM 16 binary release](https://github.com/llvm/llvm-project/releases) (`llvm-16`, `lld-16` and `clang-16` are required).

* Checkout AdaWebPack repository into `gnat-llvm/llvm-interface` as
`adawebpack_src` and create link for Makefile.target.
Expand Down Expand Up @@ -78,8 +78,9 @@ You will also need `wasm-ld`, the Web asssembly linker. You will find this:

* Apply patch to GNAT-LLVM repository
```
cd gnat-llvm
patch -p0 < llvm-interface/adawebpack_src/patches/gnat-llvm.patch
cd gnat-llvm/llvm-interface
patch -p1 < adawebpack_src/patches/gnat-llvm.patch
patch -p1 < adawebpack_src/patches/llvm_wrapper2.patch
cd -
```

Expand Down Expand Up @@ -114,27 +115,19 @@ It could be handy to use docker.
* Build a container image (make sure to replace `curl` argument with latest RPM URL)
```
docker build --tag wgprbuild - <<EOF
FROM registry.fedoraproject.org/fedora-minimal:36
FROM registry.fedoraproject.org/fedora-minimal:40
RUN microdnf --assumeyes install \
make \
rpmdevtools \
libstdc++-static \
libgnat \
clang \
llvm-devel \
lld \
gprbuild \
gdb \
git \
openssh-server \
tar \
gzip \
chrpath \
clang16 \
llvm16 \
lld \
libgnat \
ca-certificates && \
curl -O \
https://download.copr.fedorainfracloud.org/results/reznik/adawebpack/fedora-36-x86_64/05068491-adawebpack/adawebpack-22.1.0-git.fc36.x86_64.rpm && \
https://download.copr.fedorainfracloud.org/results/reznik/adawebpack/fedora-40-x86_64/07674186-adawebpack/adawebpack-24.0.0-git.fc40.x86_64.rpm && \
rpm -i adawebpack*.rpm && \
rm -f adawebpack*.rpm && \
/usr/share/adawebpack/update-alternatives-clang.sh 16 99 && \
microdnf clean all
EOF
```
Expand Down
14 changes: 7 additions & 7 deletions patches/gnat-llvm.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
diff --git llvm-interface/gnatllvm-instructions.adb llvm-interface/gnatllvm-instructions.adb
index f8066fc0..4ba3a5cc 100644
diff -aur llvm-interface/gnatllvm-instructions.adb llvm-interface/gnatllvm-instructions.adb
--- llvm-interface/gnatllvm-instructions.adb
+++ llvm-interface/gnatllvm-instructions.adb
@@ -1447,29 +1447,23 @@ package body GNATLLVM.Instructions is
Args : GL_Value_Array;
Name : String := "") return Value_T
@@ -1548,29 +1548,23 @@
Args : GL_Value_Array;
Name : String := "") return Value_T
is
- function To_Param_Num (Idx : Nat) return unsigned;
- -- Map index in Args array to LLVM parameter number
Expand Down Expand Up @@ -36,8 +35,8 @@ index f8066fc0..4ba3a5cc 100644
end loop;

-- If we have a landing pad, use an invoke instruction, first creating
@@ -1486,32 +1480,22 @@ package body GNATLLVM.Instructions is
Arg_Values'Address, Arg_Values'Length, Name);
@@ -1587,32 +1581,22 @@
Arg_Values'Address, Arg_Values'Length, Name);
end if;

- -- Set some parameter attributes based on the called function.
Expand Down Expand Up @@ -78,3 +77,4 @@ index f8066fc0..4ba3a5cc 100644
end loop;

return Call_Inst;
Only in new/gnat-llvm/llvm-interface: gnatllvm-instructions.adb.orig
Loading

0 comments on commit cd0c10a

Please sign in to comment.