Skip to content

Commit 745261f

Browse files
committed
musl
1 parent 508979c commit 745261f

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ jobs:
4343
target: x86_64-unknown-linux-gnu
4444
variant: release
4545

46+
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
47+
target: x86_64-unknown-linux-musl
48+
variant: release
49+
4650
- os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2019-xxl' || 'windows-2019' }}
4751
target: x86_64-pc-windows-msvc
4852
variant: release # Note: we do not support windows debug builds.
@@ -84,6 +88,10 @@ jobs:
8488
python-version: 3.11.x
8589
architecture: x64
8690

91+
- name: Install cross compilation toolchain (musl)
92+
if: endsWith(matrix.config.target, '-musl')
93+
run: rustup target add ${{ matrix.config.target }}
94+
8795
- name: Install cross compilation toolchain
8896
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
8997
run: |

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@
2828
[submodule "third_party/abseil-cpp"]
2929
path = third_party/abseil-cpp
3030
url = https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git
31+
[submodule "musl-cross-make"]
32+
path = musl-cross-make
33+
url = https://github.com/richfelker/musl-cross-make.git

build.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,15 @@ fn build_v8() {
123123
vec!["is_debug=false".to_string()]
124124
};
125125

126+
if std::env::var("CARGO_CFG_TARGET_ENV").map_or(false, |e| e == "musl") {
127+
build_musl_cross_make();
128+
129+
gn_args.push("use_custom_libcxx=true".to_string());
130+
gn_args.push("is_clang=false".to_string());
131+
gn_args.push("treat_warnings_as_errors=false".to_string());
132+
gn_args.push("line_tables_only=false".to_string());
133+
}
134+
126135
if cfg!(not(feature = "use_custom_libcxx")) {
127136
gn_args.push("use_custom_libcxx=false".to_string());
128137
}
@@ -310,6 +319,30 @@ fn download_ninja_gn_binaries() {
310319
env::set_var("NINJA", ninja);
311320
}
312321

322+
fn build_musl_cross_make() {
323+
let toolchain_dir = build_dir().join("musl-cross-make");
324+
if toolchain_dir.exists() {
325+
println!("musl-cross-make toolchain already exists, skipping build");
326+
}
327+
328+
std::fs::copy("config.mak", "musl-cross-make/config.mak").unwrap();
329+
Command::new("make")
330+
.arg("-C")
331+
.arg("musl-cross-make")
332+
.arg("TARGET=x86_64-linux-musl")
333+
.status()
334+
.unwrap();
335+
336+
Command::new("make")
337+
.arg("-C")
338+
.arg("musl-cross-make")
339+
.arg("TARGET=x86_64-linux-musl")
340+
.arg("install")
341+
.arg(format!("OUTPUT={}", toolchain_dir.display()))
342+
.status()
343+
.unwrap();
344+
}
345+
313346
fn static_lib_url() -> String {
314347
if let Ok(custom_archive) = env::var("RUSTY_V8_ARCHIVE") {
315348
return custom_archive;

config.mak

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MUSL_VER = 1.1.24
2+
GCC_VER = 9.2.0
3+
4+
GCC_CONFIG += --enable-default-pie
5+
6+
DL_CMD = curl -C - -L -s -o
7+
SHA1_CMD = shasum -a 1 -c

musl-cross-make

Submodule musl-cross-make added at 26bb551

0 commit comments

Comments
 (0)