Browse Source

Move to llvm 11.0 based on Solana llvm tree

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 4 years ago
parent
commit
38734ed0f5

+ 5 - 5
.github/workflows/release.yml

@@ -35,11 +35,11 @@ jobs:
     - name: Checkout sources
     - name: Checkout sources
       uses: actions/checkout@v2
       uses: actions/checkout@v2
     - name: Download LLVM
     - name: Download LLVM
-      run: curl -sS -o c:\llvm.zip https://solang.io/download/llvm10.0-win.zip
+      run: curl -sS -o c:\llvm.zip https://solang.io/download/llvm11.0-win.zip
     - name: Extract LLVM
     - name: Extract LLVM
       run: unzip c:\llvm.zip -d c:/
       run: unzip c:\llvm.zip -d c:/
     - name: Add LLVM to Path
     - name: Add LLVM to Path
-      run: echo "c:\llvm10.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
+      run: echo "c:\llvm11.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
     - name: Build
     - name: Build
       run: cargo build --release --verbose
       run: cargo build --release --verbose
     - name: Run tests
     - name: Run tests
@@ -59,11 +59,11 @@ jobs:
     - name: Checkout sources
     - name: Checkout sources
       uses: actions/checkout@v2
       uses: actions/checkout@v2
     - name: Download LLVM
     - name: Download LLVM
-      run: curl -sS -o llvm10.0-mac.tar.gz https://solang.io/download/llvm10.0-mac.tar.gz
+      run: curl -sS -o llvm11.0-mac.tar.xz https://solang.io/download/llvm11.0-mac.tar.xz
     - name: Extract LLVM
     - name: Extract LLVM
-      run: tar zxf llvm10.0-mac.tar.gz
+      run: tar Jxf llvm11.0-mac.tar.xz
     - name: Add LLVM to Path
     - name: Add LLVM to Path
-      run: echo "$(pwd)/llvm10.0/bin" >> $GITHUB_PATH
+      run: echo "$(pwd)/llvm11.0/bin" >> $GITHUB_PATH
     - name: Build
     - name: Build
       run: cargo build --release --verbose
       run: cargo build --release --verbose
     - name: Run tests
     - name: Run tests

+ 5 - 5
.github/workflows/test.yml

@@ -54,11 +54,11 @@ jobs:
         # Make sure "git describe --tags" works for solang --version
         # Make sure "git describe --tags" works for solang --version
         fetch-depth: 0
         fetch-depth: 0
     - name: Download LLVM
     - name: Download LLVM
-      run: curl -sS -o c:\llvm.zip https://solang.io/download/llvm10.0-win.zip
+      run: curl -sS -o c:\llvm.zip https://solang.io/download/llvm11.0-win.zip
     - name: Extract LLVM
     - name: Extract LLVM
       run: unzip c:\llvm.zip -d c:/
       run: unzip c:\llvm.zip -d c:/
     - name: Add LLVM to Path
     - name: Add LLVM to Path
-      run: echo "c:\llvm10.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
+      run: echo "c:\llvm11.0\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
     - name: Build
     - name: Build
       run: cargo build --verbose
       run: cargo build --verbose
     - name: Run tests
     - name: Run tests
@@ -78,11 +78,11 @@ jobs:
         # Make sure "git describe --tags" works for solang --version
         # Make sure "git describe --tags" works for solang --version
         fetch-depth: 0
         fetch-depth: 0
     - name: Download LLVM
     - name: Download LLVM
-      run: curl -sS -o llvm10.0-mac.tar.gz https://solang.io/download/llvm10.0-mac.tar.gz
+      run: curl -sS -o llvm11.0-mac.tar.xz https://solang.io/download/llvm11.0-mac.tar.xz
     - name: Extract LLVM
     - name: Extract LLVM
-      run: tar zxf llvm10.0-mac.tar.gz
+      run: tar Jxf llvm11.0-mac.tar.xz
     - name: Add LLVM to Path
     - name: Add LLVM to Path
-      run: echo "$(pwd)/llvm10.0/bin" >> $GITHUB_PATH
+      run: echo "$(pwd)/llvm11.0/bin" >> $GITHUB_PATH
     - name: Build
     - name: Build
       run: cargo build --verbose
       run: cargo build --verbose
     - name: Run tests
     - name: Run tests

+ 3 - 0
CHANGELOG.md

@@ -11,6 +11,9 @@ will be documented here.
   releases, so the user is not required to download it themselves
   releases, so the user is not required to download it themselves
 - The Solana now has support for arrays and mapping in contract storage
 - The Solana now has support for arrays and mapping in contract storage
 
 
+### Changed
+- Solang now uses LLVM 11.0, based on the [Solana LLVM tree](https://github.com/solana-labs/llvm-project/)
+
 ### Fixed
 ### Fixed
 - ewasm: staticcall() and delegatecall() cannot take value argument
 - ewasm: staticcall() and delegatecall() cannot take value argument
 - Fixed array support in the ethereum abi encoder and decoder
 - Fixed array support in the ethereum abi encoder and decoder

+ 1 - 1
Cargo.toml

@@ -28,7 +28,7 @@ tiny-keccak = { version = "2.0", features = ["keccak"] }
 serde_json = "1.0"
 serde_json = "1.0"
 serde = "1.0"
 serde = "1.0"
 serde_derive = { version = "1.0" }
 serde_derive = { version = "1.0" }
-inkwell = { version = "0.1.0-beta.2", features = ["target-webassembly", "target-bpf", "llvm10-0"] }
+inkwell = { version = "0.1.0-beta.2", features = ["target-webassembly", "target-bpf", "llvm11-0"] }
 blake2-rfc = "0.2.18"
 blake2-rfc = "0.2.18"
 phf = { version = "0.8", features = ["macros"] }
 phf = { version = "0.8", features = ["macros"] }
 unicode-xid = "0.2.0"
 unicode-xid = "0.2.0"

+ 13 - 19
docs/installing.rst

@@ -51,7 +51,7 @@ Building Solang from source
 ---------------------------
 ---------------------------
 
 
 In order to build Solang from source, you will need rust 1.48.0 or higher,
 In order to build Solang from source, you will need rust 1.48.0 or higher,
-and a build of llvm based on our tree. There are a few patches which are not upstream yet
+and a build of llvm based on the Solana llvm tree. There are a few patches which are not upstream yet.
 First, follow the steps below for installing llvm and then proceed from there.
 First, follow the steps below for installing llvm and then proceed from there.
 
 
 If you do not have the correct version of rust installed, go to `rustup <https://rustup.rs/>`_.
 If you do not have the correct version of rust installed, go to `rustup <https://rustup.rs/>`_.
@@ -60,7 +60,7 @@ Installing the LLVM Libraries
 -----------------------------
 -----------------------------
 
 
 Solang needs a build of
 Solang needs a build of
-`llvm with some extra patches <https://github.com/seanyoung/llvm-project/tree/bpf>`_.
+`llvm with some extra patches <https://github.com/solana-labs/llvm-project/>`_.
 You can either download the pre-built binaries or build your own from source. After that,
 You can either download the pre-built binaries or build your own from source. After that,
 You need to add the `bin` directory to your path, so that the build system of Solang can find the
 You need to add the `bin` directory to your path, so that the build system of Solang can find the
 correct version of llvm to use.
 correct version of llvm to use.
@@ -69,26 +69,26 @@ Installing LLVM on Linux
 ________________________
 ________________________
 
 
 A pre-built version of llvm, specifically configured for Solang, is available at
 A pre-built version of llvm, specifically configured for Solang, is available at
-`<https://solang.io/download/llvm10.0-linux.tar.gz>`_. This version is built using the
+`<https://solang.io/download/llvm11.0-linux.tar.xz>`_. This version is built using the
 `dockerfile for building llvm on linux <https://github.com/hyperledger-labs/solang/blob/main/scripts/build-llvm-linux.dockerfile>`_.
 `dockerfile for building llvm on linux <https://github.com/hyperledger-labs/solang/blob/main/scripts/build-llvm-linux.dockerfile>`_.
 After downloading, untar the file in a terminal and add it to your path.
 After downloading, untar the file in a terminal and add it to your path.
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-	tar zxf llvm10.0-linux.tar.gz
-	export PATH=$(pwd)/llvm10.0/bin:$PATH
+	tar Jxf llvm11.0-linux.tar.xz
+	export PATH=$(pwd)/llvm11.0/bin:$PATH
 
 
 Installing LLVM on Windows
 Installing LLVM on Windows
 __________________________
 __________________________
 
 
 A pre-built version of llvm, specifically configured for Solang, is available at
 A pre-built version of llvm, specifically configured for Solang, is available at
-`<https://solang.io/download/llvm10.0-win.zip>`_. This version is built using the
+`<https://solang.io/download/llvm11.0-win.zip>`_. This version is built using the
 `dockerfile for building llvm on Windows <https://github.com/hyperledger-labs/solang/blob/main/scripts/build-llvm-windows.dockerfile>`_.
 `dockerfile for building llvm on Windows <https://github.com/hyperledger-labs/solang/blob/main/scripts/build-llvm-windows.dockerfile>`_.
 
 
 If you want to use the dockerfile yourself rather than download the binaries above, then this
 If you want to use the dockerfile yourself rather than download the binaries above, then this
 requires `Docker Desktop <https://www.docker.com/products/docker-desktop>`_ installed, and then switched to
 requires `Docker Desktop <https://www.docker.com/products/docker-desktop>`_ installed, and then switched to
 `windows containers <https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers>`_.
 `windows containers <https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers>`_.
-The result will be an image with llvm compressed in the file ``c:\llvm10.0-win.zip``. Docker on Windows needs Hyper-V
+The result will be an image with llvm compressed in the file ``c:\llvm11.0-win.zip``. Docker on Windows needs Hyper-V
 enabled. If you are running Windows 10 in a virtual machine, be sure to check
 enabled. If you are running Windows 10 in a virtual machine, be sure to check
 `this blog post <https://www.mess.org/2020/06/22/Hyper-V-in-KVM/>`_.
 `this blog post <https://www.mess.org/2020/06/22/Hyper-V-in-KVM/>`_.
 
 
@@ -96,21 +96,21 @@ After unzipping the file, add the bin directory to your path.
 
 
 .. code-block:: batch
 .. code-block:: batch
 
 
-	set PATH=%PATH%;C:\llvm10.0\bin
+	set PATH=%PATH%;C:\llvm11.0\bin
 
 
 Installing LLVM on Mac
 Installing LLVM on Mac
 ______________________
 ______________________
 
 
 A pre-built version of llvm, specifically configured for Solang, is available on
 A pre-built version of llvm, specifically configured for Solang, is available on
-`<https://solang.io/download/llvm10.0-mac.tar.gz>`_. This version is built
+`<https://solang.io/download/llvm11.0-mac.tar.xz>`_. This version is built
 with the instructions below. After downloading, untar the file in a terminal and
 with the instructions below. After downloading, untar the file in a terminal and
 add it to your path.
 add it to your path.
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-	tar zxf llvm10.0-mac.tar.gz
-	xattr -rd com.apple.quarantine llvm10.0
-	export PATH=$(pwd)/llvm10.0/bin:$PATH
+	tar Jxf llvm11.0-mac.tar.xz
+	xattr -rd com.apple.quarantine llvm11.0
+	export PATH=$(pwd)/llvm11.0/bin:$PATH
 
 
 .. _llvm-from-source:
 .. _llvm-from-source:
 
 
@@ -122,15 +122,9 @@ you may need to consult. First if all clone our llvm repository:
 
 
 .. code-block:: bash
 .. code-block:: bash
 
 
-	git clone git://github.com/seanyoung/llvm-project
+	git clone git://github.com/solana-labs/llvm-project
 	cd llvm-project
 	cd llvm-project
 
 
-Now switch to the bpf branch:
-
-.. code-block:: bash
-
-	git checkout bpf
-
 Now run cmake to create the makefiles. Replace the *installdir* argument to ``CMAKE_INSTALL_PREFIX`` with with a directory where you would like to have llvm installed, and then run the build:
 Now run cmake to create the makefiles. Replace the *installdir* argument to ``CMAKE_INSTALL_PREFIX`` with with a directory where you would like to have llvm installed, and then run the build:
 
 
 .. code-block:: bash
 .. code-block:: bash

+ 5 - 5
scripts/build-llvm-linux.dockerfile

@@ -1,19 +1,19 @@
 FROM ubuntu:18.04
 FROM ubuntu:18.04
 
 
 ENV DEBIAN_FRONTEND=noninteractive
 ENV DEBIAN_FRONTEND=noninteractive
-RUN apt-get update
+RUN apt-get update -y
+RUN apt-get upgrade -y
 RUN apt-get install -y libz-dev pkg-config libssl-dev git cmake ninja-build gcc g++ python
 RUN apt-get install -y libz-dev pkg-config libssl-dev git cmake ninja-build gcc g++ python
 
 
-RUN git clone --branch bpf --single-branch \
-    git://github.com/seanyoung/llvm-project.git
+RUN git clone --single-branch git://github.com/solana-labs/llvm-project.git
 
 
 WORKDIR /llvm-project
 WORKDIR /llvm-project
 
 
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_ENABLE_TERMINFO=Off \
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_ENABLE_TERMINFO=Off \
     -DLLVM_ENABLE_PROJECTS=clang\;lld  \
     -DLLVM_ENABLE_PROJECTS=clang\;lld  \
     -DLLVM_TARGETS_TO_BUILD=WebAssembly\;BPF \
     -DLLVM_TARGETS_TO_BUILD=WebAssembly\;BPF \
-    -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/llvm10.0 llvm
+    -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/llvm11.0 llvm
 
 
 RUN cmake --build . --target install
 RUN cmake --build . --target install
 
 
-RUN tar jcf /llvm10.0-linux.tar.bz2 /llvm10.0/
+RUN tar Jcf /llvm11.0-linux.tar.xz /llvm11.0/

+ 9 - 13
scripts/build-llvm-windows.dockerfile

@@ -5,10 +5,10 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2019
 
 
 SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
 SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'Continue'; $verbosePreference='Continue';"]
 
 
-# Download Visual Studio Build Tools 16.6. This should match the version on github actions virtual environment.
+# Download Visual Studio Build Tools 16.8.3. This should match the version on github actions virtual environment.
 # https://docs.microsoft.com/en-us/visualstudio/releases/2019/history
 # https://docs.microsoft.com/en-us/visualstudio/releases/2019/history
 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md
 # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md
-ADD https://download.visualstudio.microsoft.com/download/pr/067fd8d0-753e-4161-8780-dfa3e577839e/4776935864d08e66183acd5b3647c9616da989c60afbfe100d4afc459f7e5785/vs_BuildTools.exe C:\TEMP\vs_buildtools.exe
+ADD https://download.visualstudio.microsoft.com/download/pr/9b3476ff-6d0a-4ff8-956d-270147f21cd4/0df5becfebf4ae2418f5fae653feebf3888b0af00d3df0415cb64875147e9be3/vs_BuildTools.exe C:\TEMP\vs_buildtools.exe
 
 
 # Install Visual Studio Build Tools
 # Install Visual Studio Build Tools
 RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
 RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
@@ -16,11 +16,7 @@ RUN C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache `
 	--add Microsoft.VisualStudio.Component.VC.CMake.Project `
 	--add Microsoft.VisualStudio.Component.VC.CMake.Project `
 	--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
 	--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
 	--add Microsoft.VisualStudio.Component.VC.ATL `
 	--add Microsoft.VisualStudio.Component.VC.ATL `
-	--add Microsoft.VisualStudio.Component.Windows10SDK.16299 `
-	--remove Microsoft.VisualStudio.Component.Windows10SDK.10240 `
-	--remove Microsoft.VisualStudio.Component.Windows10SDK.10586 `
-	--remove Microsoft.VisualStudio.Component.Windows10SDK.14393 `
-	--remove Microsoft.VisualStudio.Component.Windows81SDK
+	--add Microsoft.VisualStudio.Component.Windows10SDK.18362
 
 
 # Rust
 # Rust
 ADD https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe C:\TEMP\rustup-init.exe
 ADD https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe C:\TEMP\rustup-init.exe
@@ -28,9 +24,9 @@ ADD https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.
 RUN C:\TEMP\rustup-init.exe -y
 RUN C:\TEMP\rustup-init.exe -y
 
 
 # Git
 # Git
-ADD https://github.com/git-for-windows/git/releases/download/v2.28.0.windows.1/MinGit-2.28.0-64-bit.zip C:\TEMP\MinGit-2.28.0-64-bit.zip
+ADD https://github.com/git-for-windows/git/releases/download/v2.30.0.windows.1/MinGit-2.30.0-64-bit.zip C:\TEMP\MinGit-2.30.0-64-bit.zip
 
 
-RUN Expand-Archive C:\TEMP\MinGit-2.28.0-64-bit.zip -DestinationPath c:\MinGit
+RUN Expand-Archive C:\TEMP\MinGit-2.30.0-64-bit.zip -DestinationPath c:\MinGit
 
 
 # LLVM Build requires Python
 # LLVM Build requires Python
 # Newer versions than v3.5.4 fail due to https://github.com/microsoft/vcpkg/issues/6988
 # Newer versions than v3.5.4 fail due to https://github.com/microsoft/vcpkg/issues/6988
@@ -46,13 +42,13 @@ RUN Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force ; `
 
 
 # Invoke-BatchFile retains the environment after executing so we can set it up more permanently
 # Invoke-BatchFile retains the environment after executing so we can set it up more permanently
 RUN Invoke-BatchFile C:\BuildTools\vc\Auxiliary\Build\vcvars64.bat ; `
 RUN Invoke-BatchFile C:\BuildTools\vc\Auxiliary\Build\vcvars64.bat ; `
-	$path = $env:path + ';c:\MinGit\cmd;C:\Users\ContainerAdministrator\.cargo\bin;C:\llvm10.0\bin;C:\Python' ; `
+	$path = $env:path + ';c:\MinGit\cmd;C:\Users\ContainerAdministrator\.cargo\bin;C:\llvm11.0\bin;C:\Python' ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name LIB -Value $env:LIB ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name LIB -Value $env:LIB ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name INCLUDE -Value $env:INCLUDE ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name INCLUDE -Value $env:INCLUDE ; `
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name LIBPATH -Value $env:LIBPATH ;
 	Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name LIBPATH -Value $env:LIBPATH ;
 
 
-RUN git clone --branch bpf --single-branch git://github.com/seanyoung/llvm-project
+RUN git clone --single-branch git://github.com/solana-labs/llvm-project
 
 
 WORKDIR \llvm-project
 WORKDIR \llvm-project
 
 
@@ -61,12 +57,12 @@ RUN Add-Content llvm\CMakeLists.txt 'set(CMAKE_SUPPRESS_REGENERATION 1)' ;
 
 
 # All llvm targets should be enabled or inkwell refused to link
 # All llvm targets should be enabled or inkwell refused to link
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On '-DLLVM_ENABLE_PROJECTS=clang;lld' `
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On '-DLLVM_ENABLE_PROJECTS=clang;lld' `
-	-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=C:/llvm10.0 `
+	-DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=C:/llvm11.0 `
 	-B build llvm
 	-B build llvm
 RUN cmake --build build --target install
 RUN cmake --build build --target install
 
 
 WORKDIR \
 WORKDIR \
 
 
-RUN Compress-Archive -Path C:\llvm10.0 -DestinationPath C:\llvm10.0-win.zip
+RUN Compress-Archive -Path C:\llvm11.0 -DestinationPath C:\llvm11.0-win.zip
 
 
 RUN Remove-Item -Path \llvm-project,C:\TEMP -Recurse -Force
 RUN Remove-Item -Path \llvm-project,C:\TEMP -Recurse -Force

+ 6 - 6
scripts/ci.dockerfile

@@ -1,18 +1,18 @@
 FROM ubuntu:18.04 as builder
 FROM ubuntu:18.04 as builder
 
 
-RUN apt-get update
 ENV DEBIAN_FRONTEND=noninteractive
 ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update -y
+RUN apt-get upgrade -y
 RUN apt-get install -y libz-dev pkg-config libssl-dev git cmake ninja-build gcc g++ python
 RUN apt-get install -y libz-dev pkg-config libssl-dev git cmake ninja-build gcc g++ python
 
 
-RUN git clone --branch bpf --single-branch \
-    git://github.com/seanyoung/llvm-project.git
+RUN git clone --single-branch git://github.com/solana-labs/llvm-project.git
 
 
 WORKDIR /llvm-project
 WORKDIR /llvm-project
 
 
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_ENABLE_TERMINFO=Off \
 RUN cmake -G Ninja -DLLVM_ENABLE_ASSERTIONS=On -DLLVM_ENABLE_TERMINFO=Off \
     -DLLVM_ENABLE_PROJECTS=clang\;lld \
     -DLLVM_ENABLE_PROJECTS=clang\;lld \
     -DLLVM_TARGETS_TO_BUILD=WebAssembly\;BPF \
     -DLLVM_TARGETS_TO_BUILD=WebAssembly\;BPF \
-    -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/llvm10.0 llvm
+    -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_INSTALL_PREFIX=/llvm11.0 llvm
 
 
 RUN cmake --build . --target install
 RUN cmake --build . --target install
 
 
@@ -27,6 +27,6 @@ RUN apt-get autoclean
 # Get Rust
 # Get Rust
 RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.48.0
 RUN curl https://sh.rustup.rs -sSf | bash -s -- -y --default-toolchain 1.48.0
 
 
-COPY --from=builder /llvm10.0 /llvm10.0/
+COPY --from=builder /llvm11.0 /llvm11.0/
 
 
-ENV PATH="/llvm10.0/bin:/root/.cargo/bin:${PATH}"
+ENV PATH="/llvm11.0/bin:/root/.cargo/bin:${PATH}"

+ 14 - 7
src/emit/mod.rs

@@ -5283,7 +5283,6 @@ pub struct Contract<'a> {
     math_overflow_check: bool,
     math_overflow_check: bool,
     builder: Builder<'a>,
     builder: Builder<'a>,
     context: &'a Context,
     context: &'a Context,
-    triple: TargetTriple,
     contract: &'a ast::Contract,
     contract: &'a ast::Contract,
     ns: &'a ast::Namespace,
     ns: &'a ast::Namespace,
     functions: HashMap<usize, FunctionValue<'a>>,
     functions: HashMap<usize, FunctionValue<'a>>,
@@ -5379,9 +5378,9 @@ impl<'a> Contract<'a> {
 
 
         let target_machine = target
         let target_machine = target
             .create_target_machine(
             .create_target_machine(
-                &self.triple,
-                "",
+                &self.ns.target.llvm_target_triple(),
                 "",
                 "",
+                self.ns.target.llvm_features(),
                 self.opt,
                 self.opt,
                 RelocMode::Default,
                 RelocMode::Default,
                 CodeModel::Default,
                 CodeModel::Default,
@@ -5467,7 +5466,7 @@ impl<'a> Contract<'a> {
     ) -> Self {
     ) -> Self {
         lazy_static::initialize(&LLVM_INIT);
         lazy_static::initialize(&LLVM_INIT);
 
 
-        let triple = TargetTriple::create(ns.target.llvm_target_triple());
+        let triple = ns.target.llvm_target_triple();
         let module = context.create_module(&contract.name);
         let module = context.create_module(&contract.name);
 
 
         module.set_triple(&triple);
         module.set_triple(&triple);
@@ -5535,7 +5534,6 @@ impl<'a> Contract<'a> {
             constructor_abort_value_transfers,
             constructor_abort_value_transfers,
             math_overflow_check,
             math_overflow_check,
             builder: context.create_builder(),
             builder: context.create_builder(),
-            triple,
             context,
             context,
             contract,
             contract,
             ns,
             ns,
@@ -6504,11 +6502,20 @@ impl Target {
     }
     }
 
 
     /// LLVM Target triple
     /// LLVM Target triple
-    fn llvm_target_triple(&self) -> &'static str {
-        if *self == Target::Solana {
+    fn llvm_target_triple(&self) -> TargetTriple {
+        TargetTriple::create(if *self == Target::Solana {
             "bpfel-unknown-unknown"
             "bpfel-unknown-unknown"
         } else {
         } else {
             "wasm32-unknown-unknown-wasm"
             "wasm32-unknown-unknown-wasm"
+        })
+    }
+
+    /// LLVM Target triple
+    fn llvm_features(&self) -> &'static str {
+        if *self == Target::Solana {
+            "+solana"
+        } else {
+            ""
         }
         }
     }
     }
 
 

+ 3 - 2
src/linker/bpf.rs

@@ -45,9 +45,10 @@ PHDRS
 SECTIONS
 SECTIONS
 {
 {
     . = SIZEOF_HEADERS;
     . = SIZEOF_HEADERS;
-    .text : { *(.text) } :text
-    .rodata : { *(.rodata) } :rodata
+    .text : { *(.text*) } :text
+    .rodata : { *(.rodata*) } :rodata
     .dynamic : { *(.dynamic) } :dynamic
     .dynamic : { *(.dynamic) } :dynamic
+    .data.rel.ro : { *(.data.rel.ro*) } :dynamic
     .dynsym : { *(.dynsym) } :dynamic
     .dynsym : { *(.dynsym) } :dynamic
     .dynstr : { *(.dynstr) } :dynamic
     .dynstr : { *(.dynstr) } :dynamic
     .gnu.hash : { *(.gnu.hash) } :dynamic
     .gnu.hash : { *(.gnu.hash) } :dynamic

+ 3 - 3
stdlib/Makefile

@@ -1,5 +1,5 @@
 CC=clang
 CC=clang
-CFLAGS=--target=$(TARGET) -emit-llvm -O3 -ffreestanding -fno-builtin -Wall -Wno-unused-function
+CFLAGS=$(TARGET_FLAGS) -emit-llvm -O3 -ffreestanding -fno-builtin -Wall -Wno-unused-function
 
 
 bpf/%.bc wasm/%.bc: %.c
 bpf/%.bc wasm/%.bc: %.c
 	$(CC) -c $(CFLAGS) $< -o $@
 	$(CC) -c $(CFLAGS) $< -o $@
@@ -9,5 +9,5 @@ WASM=$(addprefix wasm/,ripemd160.bc stdlib.bc substrate.bc bigint.bc format.bc w
 
 
 all: $(SOLANA) $(WASM)
 all: $(SOLANA) $(WASM)
 
 
-$(SOLANA): TARGET=bpf
-$(WASM): TARGET=wasm32
+$(SOLANA): TARGET_FLAGS=--target=bpfel -march=bpfel+solana
+$(WASM): TARGET_FLAGS=--target=wasm32

BIN
stdlib/bpf/bigint.bc


BIN
stdlib/bpf/format.bc


BIN
stdlib/bpf/solana.bc


BIN
stdlib/bpf/stdlib.bc


BIN
stdlib/wasm/keccak256.bc


BIN
stdlib/wasm/ripemd160.bc


BIN
stdlib/wasm/stdlib.bc


BIN
stdlib/wasm/substrate.bc


BIN
stdlib/wasm/wasmheap.bc