Skip to content

Commit

Permalink
fix(cross): compiler-rt building
Browse files Browse the repository at this point in the history
  • Loading branch information
llenotre committed May 17, 2024
1 parent 08ea1ff commit 3388075
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
5 changes: 2 additions & 3 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ impl Environment {
///
/// The key is the name of the package and the value is the installed package.
pub fn load_installed_list(&self) -> io::Result<HashMap<String, InstalledPackage>> {
let path = util::concat_paths(&self.sysroot, Path::new(INSTALLED_FILE));

let path = util::concat_paths(&self.sysroot, INSTALLED_FILE);
match util::read_json::<HashMap<String, InstalledPackage>>(&path) {
Ok(pkgs) => Ok(pkgs),
Err(e) if e.kind() == ErrorKind::NotFound => Ok(HashMap::new()),
Expand All @@ -87,7 +86,7 @@ impl Environment {
&self,
list: &HashMap<String, InstalledPackage>,
) -> io::Result<()> {
let path = util::concat_paths(&self.sysroot, Path::new(INSTALLED_FILE));
let path = util::concat_paths(&self.sysroot, INSTALLED_FILE);
util::write_json(&path, list)
}

Expand Down
3 changes: 2 additions & 1 deletion cross/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
toolchain/
work/
toolchain/
4 changes: 2 additions & 2 deletions cross/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
# Prepare
mkdir -p toolchain/repo
PATH="$(pwd)/../target/release:$PATH"
export SYSROOT="$(pwd)/toolchain/"
export SYSROOT="toolchain/"
export LOCAL_REPO="toolchain/repo/"

# binutils
Expand All @@ -25,4 +25,4 @@ yes | blimp install musl

# clang
blimp-builder desc/clang toolchain/repo/
yes | blimp install clang
yes | blimp install clang
9 changes: 5 additions & 4 deletions cross/desc/clang/build-hook
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ cd ..

# Build compiler-rt
cd compiler-rt-build
cmake \
LDFLAGS="-nostdlib" cmake \
../llvm/compiler-rt \
-G Ninja \
-DCMAKE_C_COMPILER="$SYSROOT/bin/clang" \
Expand All @@ -62,13 +62,14 @@ cmake \
-DCOMPILER_RT_BUILD_ORC=ON \
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
-DCOMPILER_RT_BUILTINS_ENABLE_PIC=OFF \
-DCMAKE_INSTALL_PREFIX="$SYSROOT/lib/clang/13.0.1/"
-DCMAKE_INSTALL_PREFIX="$SYSROOT/lib/clang/$PKG_VERSION/"
ninja -j$JOBS
ninja -j$JOBS install
cd ..

# Patch
ln -fsv ../../lib/clang/13.0.1/lib/linux/clang_rt.crtbegin-i386.o "$SYSROOT/usr/lib/crtbegin.o"
mkdir -p "$SYSROOT/usr/lib"
ln -fsv "../../lib/clang/$PKG_VERSION/lib/linux/clang_rt.crtbegin-i386.o" "$SYSROOT/usr/lib/crtbegin.o"
ln -fsv crtbegin.o "$SYSROOT/usr/lib/crtbeginS.o"
ln -fsv crtbegin.o "$SYSROOT/usr/lib/crtbeginT.o"
ln -fsv ../../lib/clang/13.0.1/lib/linux/clang_rt.crtend-i386.o "$SYSROOT/usr/lib/crtend.o"
ln -fsv "../../lib/clang/$PKG_VERSION/lib/linux/clang_rt.crtend-i386.o" "$SYSROOT/usr/lib/crtend.o"

0 comments on commit 3388075

Please sign in to comment.