How to inference `-C target-feature=+crt-static`
The musl build target is slow, how to build libc but with static build in this action, see https://stackoverflow.com/questions/58526782/how-can-i-create-a-static-executable-with-rustc-using-glibc-instead-of-musl
- As for most
*linux-musl*targets, static linking is currently enabled by default, so no additional thing is needed. - As for others, (if crt-static is respected by that target) you just need to set env vars.
- However, glibc is not suitable for static linking, so static linking
*linux-gnu*targets may cause crashes or other odd behaviors.
- However, glibc is not suitable for static linking, so static linking
- If you have performance problems with the
*linux-musl*binary, it is recommended that you use another high-performance allocator instead of the musl allocator, which is known for its suboptimal performance.- For example,
ripgrepusesjemallocator.
- For example,
As for others, (if crt-static is respected by that target) you just need to set env vars.
Ah, if you use cross (upload-rust-binary-action@v1's default cross-compile tool), you may need to propagate env vars in Cross.toml.
They have already fixed that issue in the main branch, but I don't remember if that fix was available in the version released to crates.io.
https://github.com/cross-rs/cross/wiki/Configuration#environment-variable-passthrough
Yes, I figure out the jemalloc for musl target with,
//Cargo.toml
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.5"
//main.rs
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
use jemallocator::Jemalloc;
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
how to pass the env RUSTFLAGS="-C target-feature=+crt-static" in taiki-e/upload-rust-binary-action@v1 without modify existed Cargo.toml for gnu target?
how to pass the env
RUSTFLAGS="-C target-feature=+crt-static"intaiki-e/upload-rust-binary-action@v1without modify existedCargo.tomlfor gnu target?
There are two ways.
-
Append
RUSTFLAGS=...toGITHUB_ENVas is done in the actual use case linked in the readme: https://github.com/taiki-e/cargo-hack/blob/202e6e59d491c9202ce148c9ef423853267226db/.github/workflows/release.yml#L73-L74 -
Set
RUSTFLAGS: ...via theenvfield as in the profile options described in the readme. (You can use matrix to pass flags only to specific targets.)
Yes, it works for
- target: x86_64-unknown-linux-gnu
platform: ubuntu-latest
- target: aarch64-unknown-linux-gnu
platform: ubuntu-latest
- target: powerpc64le-unknown-linux-gnu
platform: ubuntu-latest
- target: s390x-unknown-linux-gnu
platform: ubuntu-latest
- target: riscv64gc-unknown-linux-gnu
platform: ubuntu-latest
- target: mipsel-unknown-linux-gnu
platform: ubuntu-latest
- target: aarch64-apple-darwin
platform: macos-latest
- target: x86_64-apple-darwin
platform: macos-latest
- target: x86_64-pc-windows-gnu
platform: windows-latest
- target: x86_64-pc-windows-msvc
platform: windows-latest
- target: x86_64-unknown-linux-musl
platform: ubuntu-latest
- target: aarch64-unknown-linux-musl
platform: ubuntu-latest
with:
cross-build:
name: publish - ${{ inputs.target }}
runs-on: ${{ inputs.platform }}
needs:
- ready
steps:
- uses: actions/checkout@v4
- name: Set LTO to true (Windows)
if: runner.os == 'Windows'
run: |
$fileContent = Get-Content ./Cargo.toml
$fileContent = $fileContent -replace 'lto = false', 'lto = true'
Set-Content ./Cargo.toml $fileContent
- name: Set LTO to true (Linux/macOS)
if: runner.os != 'Windows'
run: perl -pi -e 's/lto = false/lto = true/g' ./Cargo.toml
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: nightly
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
if: endsWith(inputs.target, 'windows-msvc')
- uses: taiki-e/[email protected]
with:
bin: ${{ needs.ready.outputs.name }}
target: ${{ inputs.target }}
ref: refs/tags/${{ needs.ready.outputs.version }}
tar: all
zip: windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true
However, how to make it work for:
- target: powerpc64le-unknown-linux-musl
platform: ubuntu-latest
- target: s390x-unknown-linux-musl
platform: ubuntu-latest
- target: riscv64gc-unknown-linux-musl
platform: ubuntu-latest
- target: mipsel-unknown-linux-musl
platform: ubuntu-latest
since, there are https://github.com/rust-lang/rust/blob/e6381a7f37402dd5f346256b3773ae2e72853fc3/src/tools/build-manifest/src/main.rs#L94 and https://doc.rust-lang.org/nightly/rustc/platform-support.html
You can use setup-cross-toolchain-action for other musl targets. (see https://github.com/taiki-e/upload-rust-binary-action?tab=readme-ov-file#setup-cross-toolchain-action)
As for powerpc64le-unknown-linux-musl and riscv64gc-unknown-linux-musl, they are tier 2 at least on nightly, so they should work as others.
As for s390x-unknown-linux-musl and mipsel-unknown-linux-musl, they are tier 3 (i.e., effectively nightly-only targets) and no prebuilt libraries are provided, so doing static linking is complex: https://github.com/taiki-e/rust-cross-toolchain/blob/d03985a569b6d753296e8467842daf0dd409970d/docker/test/test.sh#L336-L407 Also mipsel-unknown-linux-musl is a target that uses dynamic linking by default, so you also need to set env vars to change it.
still returns:
Installed package `cross v0.2.5` (executables `cross`, `cross-util`)
+ cross build --release --bin sample --target powerpc64le-unknown-linux-musl
[cross] warning: `cross` does not provide a Docker image for target powerpc64le-unknown-linux-musl, specify a custom image in `Cross.toml`.
[cross] note: Falling back to `cargo` on the host.
Compiling proc-macro2 v1.0.93
Compiling unicode-ident v1.0.16
Compiling libc v0.2.169
Compiling cfg-if v1.0.0
error[E0463]: can't find crate for `core`
|
= note: the `powerpc64le-unknown-linux-musl` target may not be installed
= help: consider downloading the target with `rustup target add powerpc64le-unknown-linux-musl`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
and,
+ cross build --release --bin sample --target riscv64gc-unknown-linux-musl
[cross] warning: `cross` does not provide a Docker image for target riscv64gc-unknown-linux-musl, specify a custom image in `Cross.toml`.
[cross] note: Falling back to `cargo` on the host.
Compiling proc-macro2 v1.0.93
Compiling unicode-ident v1.0.16
Compiling libc v0.2.169
Compiling cfg-if v1.0.0
error[E0463]: can't find crate for `core`
|
= note: the `riscv64gc-unknown-linux-musl` target may not be installed
= help: consider downloading the target with `rustup target add riscv64gc-unknown-linux-musl`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
after have:
cross-build:
name: publish - ${{ inputs.target }}
runs-on: ${{ inputs.platform }}
needs:
- ready
steps:
- uses: actions/checkout@v4
- name: Set LTO to true (Windows)
if: runner.os == 'Windows'
run: |
$fileContent = Get-Content ./Cargo.toml
$fileContent = $fileContent -replace 'lto = false', 'lto = true'
Set-Content ./Cargo.toml $fileContent
- name: Set LTO to true (Linux/macOS)
if: runner.os != 'Windows'
run: perl -pi -e 's/lto = false/lto = true/g' ./Cargo.toml
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: nightly
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}
if: startsWith(matrix.os, 'ubuntu')
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
if: endsWith(inputs.target, 'windows-msvc')
- uses: taiki-e/[email protected]
with:
bin: ${{ needs.ready.outputs.name }}
target: ${{ inputs.target }}
ref: refs/tags/${{ needs.ready.outputs.version }}
tar: all
zip: windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true
seems that setup-cross-toolchain-action:v1 not work for
- target: powerpc64le-unknown-linux-musl
platform: ubuntu-latest
- target: riscv64gc-unknown-linux-musl
platform: ubuntu-latest
runs-on: ${{ inputs.platform }}
target: ${{ inputs.target }}
Your workflow is using inputs.platform and inputs.target to specify platform/target, but some refer to matrix.os and matrix.target which do not exist.
- name: Install cross-compilation tools uses: taiki-e/setup-cross-toolchain-action@v1 with: target: ${{ matrix.target }} if: startsWith(matrix.os, 'ubuntu')
You need to consistently refer to inputs.platform and inputs.target.
And even mipsel-unknown-linux-gnu not work,
- target: mipsel-unknown-linux-gnu
platform: ubuntu-latest
reported that,
Status: Downloaded newer image for ghcr.io/cross-rs/mipsel-unknown-linux-gnu:0.2.5
Compiling proc-macro2 v1.0.93
Compiling unicode-ident v1.0.16
Compiling cfg-if v1.0.0
error[E0463]: can't find crate for `core`
|
= note: the `mipsel-unknown-linux-gnu` target may not be installed
= help: consider downloading the target with `rustup target add mipsel-unknown-linux-gnu`
= help: consider building the standard library from source with `cargo build -Zbuild-std`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
WARN rustc_codegen_ssa::back::link The linker driver does not support `-fuse-ld=lld`. Retrying without it.
[cross] warning: rust-std is not available for mipsel-unknown-linux-gnu
[cross] note: you may need to build components for the target via `-Z build-std=<components>` or in your cross configuration specify `target.mipsel-unknown-linux-gnu.build-std`
the available components are core, std, alloc, and proc_macro
Error: Process completed with exit code 101.
reported that,
Status: Downloaded newer image for ghcr.io/cross-rs/mipsel-unknown-linux-gnu:0.2.5
That issue is the same issue as the one I mentioned in https://github.com/taiki-e/upload-rust-binary-action/issues/94#issuecomment-2666489330.
I see, looks like they dont support the allocator,
warning: [email protected]+5.3.0-patched: "`background_threads_runtime_support` not supported for `riscv64gc-unknown-linux-musl`"
error: failed to run custom build command for `jemalloc-sys v0.5.4+5.3.0-patched`
Caused by:
process didn't exit successfully: `/home/runner/work/sample/sample/target/release/build/jemalloc-sys-a57be0757e150ee9/build-script-build` (exit status: 101)
--- stdout
TARGET=riscv64gc-unknown-linux-musl
HOST=x86_64-unknown-linux-gnu
NUM_JOBS=2
OUT_DIR="/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
BUILD_DIR="/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build"
SRC_DIR="/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jemalloc-sys-0.5.4+5.3.0-patched"
cargo:rustc-cfg=prefixed
cargo:rerun-if-env-changed=JEMALLOC_OVERRIDE
OPT_LEVEL = Some(3)
OUT_DIR = Some(/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out)
TARGET = Some(riscv64gc-unknown-linux-musl)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CC_riscv64gc-unknown-linux-musl
CC_riscv64gc-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_riscv64gc_unknown_linux_musl
CC_riscv64gc_unknown_linux_musl = Some(riscv64gc-unknown-linux-musl-gcc)
cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
CC_KNOWN_WRAPPER_CUSTOM = None
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(false)
CARGO_CFG_TARGET_FEATURE = Some(a,c,d,f,m,zaamo,zalrsc)
cargo:rerun-if-env-changed=CFLAGS_riscv64gc-unknown-linux-musl
CFLAGS_riscv64gc-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_riscv64gc_unknown_linux_musl
CFLAGS_riscv64gc_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
CARGO_ENCODED_RUSTFLAGS = Some()
CC="riscv64gc-unknown-linux-musl-gcc"
CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall"
JEMALLOC_REPO_DIR="jemalloc"
cargo:warning="`background_threads_runtime_support` not supported for `riscv64gc-unknown-linux-musl`"
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_MALLOC_CONF
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_PAGE
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_HUGEPAGE
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_QUANTUM
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_VADDR
--with-jemalloc-prefix=_rjem_
running: cd "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build" && CC="riscv64gc-unknown-linux-musl-gcc" CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" CPPFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" LDFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" "sh" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/configure" "--disable-cxx" "--enable-doc=no" "--enable-shared=no" "--with-jemalloc-prefix=_rjem_" "--with-private-namespace=_rjem_" "--host=riscv64gc-unknown-linux-musl" "--build=x86_64-unknown-linux-gnu" "--prefix=/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
checking for xsltproc... false
checking for riscv64gc-unknown-linux-musl-gcc... riscv64gc-unknown-linux-musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether riscv64gc-unknown-linux-musl-gcc accepts -g... yes
checking for riscv64gc-unknown-linux-musl-gcc option to accept ISO C89... none needed
checking whether compiler is cray... no
checking whether compiler supports -std=gnu11... yes
checking whether compiler supports -Werror=unknown-warning-option... no
checking whether compiler supports -Wall... yes
checking whether compiler supports -Wextra... yes
checking whether compiler supports -Wshorten-64-to-32... no
checking whether compiler supports -Wsign-compare... yes
checking whether compiler supports -Wundef... yes
checking whether compiler supports -Wno-format-zero-length... yes
checking whether compiler supports -Wpointer-arith... yes
checking whether compiler supports -Wno-missing-braces... yes
checking whether compiler supports -Wno-missing-field-initializers... yes
checking whether compiler supports -Wno-missing-attributes... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... riscv64gc-unknown-linux-musl-gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... running: "tail" "-n" "100" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/config.log"
dvidir='${docdir}'
enable_autogen=''
enable_cache_oblivious=''
enable_cxx='0'
enable_debug=''
enable_doc='no'
enable_experimental_smallocx=''
enable_fill=''
enable_initial_exec_tls=''
enable_lazy_lock=''
enable_log=''
enable_opt_safety_checks=''
enable_opt_size_checks=''
enable_prof=''
enable_readlinkat=''
enable_shared='no'
enable_static=''
enable_stats=''
enable_tls=''
enable_uaf_detection=''
enable_utrace=''
enable_xmalloc=''
enable_zone_allocator=''
exe=''
exec_prefix='/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out'
host='riscv64gc-unknown-linux-musl'
host_alias='riscv64gc-unknown-linux-musl'
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
importlib=''
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_suffix=''
je_=''
jemalloc_version=''
jemalloc_version_bugfix=''
jemalloc_version_gid=''
jemalloc_version_major=''
jemalloc_version_minor=''
jemalloc_version_nrev=''
libdir='${exec_prefix}/lib'
libdl=''
libexecdir='${exec_prefix}/libexec'
libprefix=''
link_whole_archive=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
o=''
objroot=''
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out'
private_namespace=''
program_transform_name='s,x,x,'
psdir='${docdir}'
rev='2'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
so=''
srcroot=''
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define JEMALLOC_HAS_RESTRICT
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define SIZEOF_VOID_P 8
#define LG_SIZEOF_PTR 3
#define SIZEOF_INT 4
#define LG_SIZEOF_INT 2
#define SIZEOF_LONG 8
#define LG_SIZEOF_LONG 3
#define SIZEOF_LONG_LONG 8
#define LG_SIZEOF_LONG_LONG 3
#define SIZEOF_INTMAX_T 8
#define LG_SIZEOF_INTMAX_T 3
configure: exit 1
--- stderr
Invalid configuration `riscv64gc-unknown-linux-musl': machine `riscv64gc-unknown' not recognized
configure: error: /bin/bash build-aux/config.sub riscv64gc-unknown-linux-musl failed
thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-1[949](https://github.com/AUTOM77/sample/actions/runs/13397258735/job/37419335254#step:8:951)cf8c6b5b557f/jemalloc-sys-0.5.4+5.3.0-patched/build.rs:351:9:
command did not execute successfully: cd "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build" && CC="riscv64gc-unknown-linux-musl-gcc" CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" CPPFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" LDFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" "sh" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/configure" "--disable-cxx" "--enable-doc=no" "--enable-shared=no" "--with-jemalloc-prefix=_rjem_" "--with-private-namespace=_rjem_" "--host=riscv64gc-unknown-linux-musl" "--build=x86_64-unknown-linux-gnu" "--prefix=/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
expected success, got: exit status: 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
And for
reported that,
Status: Downloaded newer image for ghcr.io/cross-rs/mipsel-unknown-linux-gnu:0.2.5That issue is the same issue as the one I mentioned in #94 (comment).
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
Sometimes not all components are available in any given nightly.
Error: Process completed with exit code 1.
I see, looks like they dont support the allocator,
Invalid configuration `riscv64gc-unknown-linux-musl': machine `riscv64gc-unknown' not recognized configure: error: /bin/bash build-aux/config.sub riscv64gc-unknown-linux-musl failed
This issue seems to be due to the way jemalloc guess the target. I believe we can adjust setup-cross-toolchain-action to avoid this issue.
error: component 'rust-std' for target 'mipsel-unknown-linux-gnu' is unavailable for download for channel 'nightly'
This is an expected error given build-tool=cargo for this action does not yet support tier 3 targets.
We can add support for tier 3 targets, but tier 3 is tier 3 because it is experimental in the first place. Do you really need it?
This issue seems to be due to the way jemalloc guess the target. I believe we can adjust setup-cross-toolchain-action to avoid this issue.
How to adjust the setup-cross-toolchain-action to fix the issue,currently powerpc64le-unknown-linux-musl and riscv64gc-unknown-linux-gnu can work, but riscv64gc-unknown-linux-musl did not.
Also for s390x,
- target: s390x-unknown-linux-musl
platform: ubuntu-latest
error reported,
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x[86](https://github.com/MassiveDL/sample/actions/runs/13407560319/job/37450214328#step:8:88)_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's3[90](https://github.com/MassiveDL/sample/actions/runs/13407560319/job/37450214328#step:8:92)x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
error: toolchain 'nightly-x86_64-unknown-linux-gnu' does not support target 's390x-unknown-linux-musl'
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
Error: Process completed with exit code 1.
riscv64gc-unknown-linux-musl jemalloc configure script issue should be addressed in the latest setup-cross-toolchain-action@v1 (https://github.com/taiki-e/setup-cross-toolchain-action/commit/9547f7321b5533797e04789a9fb6602c2554e8ce).
The error in s390x-unknown-linux-musl is the same issue as mipsel-unknown-linux-gnu mentioned in https://github.com/taiki-e/upload-rust-binary-action/issues/94#issuecomment-2666590422, which is obvious since the message is equivalent to mipsel-unknown-linux-gnu and is the same tier 3 target as mipsel-unknown-linux-gnu.
riscv64gc-unknown-linux-musl jemalloc configure script issue should be addressed in the latest setup-cross-toolchain-action@v1
Same issue as before,
warning: [email protected]+5.3.0-patched: "`background_threads_runtime_support` not supported for `riscv64gc-unknown-linux-musl`"
error: failed to run custom build command for `jemalloc-sys v0.5.4+5.3.0-patched`
Caused by:
process didn't exit successfully: `/home/runner/work/sample/sample/target/release/build/jemalloc-sys-a57be0757e150ee9/build-script-build` (exit status: 101)
--- stdout
TARGET=riscv64gc-unknown-linux-musl
HOST=x86_64-unknown-linux-gnu
NUM_JOBS=2
OUT_DIR="/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
BUILD_DIR="/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build"
SRC_DIR="/home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/jemalloc-sys-0.5.4+5.3.0-patched"
cargo:rustc-cfg=prefixed
cargo:rerun-if-env-changed=JEMALLOC_OVERRIDE
OPT_LEVEL = Some(3)
OUT_DIR = Some(/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out)
TARGET = Some(riscv64gc-unknown-linux-musl)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CC_riscv64gc-unknown-linux-musl
CC_riscv64gc-unknown-linux-musl = None
cargo:rerun-if-env-changed=CC_riscv64gc_unknown_linux_musl
CC_riscv64gc_unknown_linux_musl = Some(riscv64-linux-musl-gcc)
cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
CC_KNOWN_WRAPPER_CUSTOM = None
RUSTC_WRAPPER = None
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(false)
CARGO_CFG_TARGET_FEATURE = Some(a,c,d,f,m,zaamo,zalrsc)
cargo:rerun-if-env-changed=CFLAGS_riscv64gc-unknown-linux-musl
CFLAGS_riscv64gc-unknown-linux-musl = None
cargo:rerun-if-env-changed=CFLAGS_riscv64gc_unknown_linux_musl
CFLAGS_riscv64gc_unknown_linux_musl = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = None
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
CARGO_ENCODED_RUSTFLAGS = Some()
CC="riscv64-linux-musl-gcc"
CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall"
JEMALLOC_REPO_DIR="jemalloc"
cargo:warning="`background_threads_runtime_support` not supported for `riscv64gc-unknown-linux-musl`"
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_MALLOC_CONF
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_PAGE
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_HUGEPAGE
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_QUANTUM
cargo:rerun-if-env-changed=JEMALLOC_SYS_WITH_LG_VADDR
--with-jemalloc-prefix=_rjem_
running: cd "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build" && CC="riscv64-linux-musl-gcc" CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" CPPFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" LDFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" "sh" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/configure" "--disable-cxx" "--enable-doc=no" "--enable-shared=no" "--with-jemalloc-prefix=_rjem_" "--with-private-namespace=_rjem_" "--host=riscv64gc-unknown-linux-musl" "--build=x86_64-unknown-linux-gnu" "--prefix=/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
checking for xsltproc... false
checking for riscv64gc-unknown-linux-musl-gcc... riscv64-linux-musl-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether riscv64-linux-musl-gcc accepts -g... yes
checking for riscv64-linux-musl-gcc option to accept ISO C89... none needed
checking whether compiler is cray... no
checking whether compiler supports -std=gnu11... yes
checking whether compiler supports -Werror=unknown-warning-option... no
checking whether compiler supports -Wall... yes
checking whether compiler supports -Wextra... yes
checking whether compiler supports -Wshorten-64-to-32... no
checking whether compiler supports -Wsign-compare... yes
checking whether compiler supports -Wundef... yes
checking whether compiler supports -Wno-format-zero-length... yes
checking whether compiler supports -Wpointer-arith... yes
checking whether compiler supports -Wno-missing-braces... yes
checking whether compiler supports -Wno-missing-field-initializers... yes
checking whether compiler supports -Wno-missing-attributes... yes
checking whether compiler supports -pipe... yes
checking whether compiler supports -g3... yes
checking how to run the C preprocessor... riscv64-linux-musl-gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking size of void *... 8
checking size of int... 4
checking size of long... 8
checking size of long long... 8
checking size of intmax_t... 8
checking build system type... x86_64-unknown-linux-gnu
checking host system type... running: "tail" "-n" "100" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/config.log"
dvidir='${docdir}'
enable_autogen=''
enable_cache_oblivious=''
enable_cxx='0'
enable_debug=''
enable_doc='no'
enable_experimental_smallocx=''
enable_fill=''
enable_initial_exec_tls=''
enable_lazy_lock=''
enable_log=''
enable_opt_safety_checks=''
enable_opt_size_checks=''
enable_prof=''
enable_readlinkat=''
enable_shared='no'
enable_static=''
enable_stats=''
enable_tls=''
enable_uaf_detection=''
enable_utrace=''
enable_xmalloc=''
enable_zone_allocator=''
exe=''
exec_prefix='/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out'
host='riscv64gc-unknown-linux-musl'
host_alias='riscv64gc-unknown-linux-musl'
host_cpu=''
host_os=''
host_vendor=''
htmldir='${docdir}'
importlib=''
includedir='${prefix}/include'
infodir='${datarootdir}/info'
install_suffix=''
je_=''
jemalloc_version=''
jemalloc_version_bugfix=''
jemalloc_version_gid=''
jemalloc_version_major=''
jemalloc_version_minor=''
jemalloc_version_nrev=''
libdir='${exec_prefix}/lib'
libdl=''
libexecdir='${exec_prefix}/libexec'
libprefix=''
link_whole_archive=''
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
o=''
objroot=''
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out'
private_namespace=''
program_transform_name='s,x,x,'
psdir='${docdir}'
rev='2'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
so=''
srcroot=''
sysconfdir='${prefix}/etc'
target_alias=''
## ----------- ##
## confdefs.h. ##
## ----------- ##
/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
#define JEMALLOC_HAS_RESTRICT
#define STDC_HEADERS 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_MEMORY_H 1
#define HAVE_STRINGS_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNISTD_H 1
#define SIZEOF_VOID_P 8
#define LG_SIZEOF_PTR 3
#define SIZEOF_INT 4
#define LG_SIZEOF_INT 2
#define SIZEOF_LONG 8
#define LG_SIZEOF_LONG 3
#define SIZEOF_LONG_LONG 8
#define LG_SIZEOF_LONG_LONG 3
#define SIZEOF_INTMAX_T 8
#define LG_SIZEOF_INTMAX_T 3
configure: exit 1
--- stderr
Invalid configuration `riscv64gc-unknown-linux-musl': machine `riscv64gc-unknown' not recognized
configure: error: /bin/bash build-aux/config.sub riscv64gc-unknown-linux-musl failed
thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-1[949](https://github.com/MassiveDL/sample/actions/runs/13419090461/job/37487182899#step:8:951)cf8c6b5b557f/jemalloc-sys-0.5.4+5.3.0-patched/build.rs:351:9:
command did not execute successfully: cd "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build" && CC="riscv64-linux-musl-gcc" CFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" CPPFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" LDFLAGS="-O3 -ffunction-sections -fdata-sections -fPIC -march=rv64gc -mabi=lp64d -Wall" "sh" "/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out/build/configure" "--disable-cxx" "--enable-doc=no" "--enable-shared=no" "--with-jemalloc-prefix=_rjem_" "--with-private-namespace=_rjem_" "--host=riscv64gc-unknown-linux-musl" "--build=x86_64-unknown-linux-gnu" "--prefix=/home/runner/work/sample/sample/target/riscv64gc-unknown-linux-musl/release/build/jemalloc-sys-f4fca63167113081/out"
expected success, got: exit status: 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Error: Process completed with exit code 101.
with new taiki-e/[email protected],
cross-build:
name: publish - ${{ inputs.target }}
runs-on: ${{ inputs.platform }}
needs:
- ready
steps:
- uses: actions/checkout@v4
- name: Set LTO to true (Windows)
if: runner.os == 'Windows'
run: |
$fileContent = Get-Content ./Cargo.toml
$fileContent = $fileContent -replace 'lto = false', 'lto = true'
Set-Content ./Cargo.toml $fileContent
- name: Set LTO to true (Linux/macOS)
if: runner.os != 'Windows'
run: perl -pi -e 's/lto = false/lto = true/g' ./Cargo.toml
- uses: taiki-e/github-actions/install-rust@main
with:
toolchain: nightly
- name: Install cross-compilation tools
uses: taiki-e/[email protected]
with:
target: ${{ inputs.target }}
if: contains(inputs.target, 'linux-musl')
- run: echo "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >> "${GITHUB_ENV}"
if: endsWith(inputs.target, 'windows-msvc')
- uses: taiki-e/[email protected]
with:
bin: ${{ needs.ready.outputs.name }}
target: ${{ inputs.target }}
ref: refs/tags/${{ needs.ready.outputs.version }}
tar: all
zip: windows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 1
CARGO_PROFILE_RELEASE_LTO: true
How to fix the jemalloc issue for,
- target: riscv64gc-unknown-linux-musl
platform: ubuntu-latest
I have the Cargo.toml,
[target.'cfg(all(target_env = "musl", target_pointer_width = "64"))'.dependencies.jemallocator]
version = "0.5"
[target.'cfg(not(all(target_env = "musl", target_pointer_width = "64")))'.dependencies.mimalloc]
version = "0.1"
and inference in main.rs
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
use jemallocator::Jemalloc;
#[cfg(not(all(target_env = "musl", target_pointer_width = "64")))]
use mimalloc::MiMalloc;
#[cfg(all(target_env = "musl", target_pointer_width = "64"))]
#[global_allocator]
static GLOBAL: Jemalloc = Jemalloc;
#[cfg(not(all(target_env = "musl", target_pointer_width = "64")))]
#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
Oh, it is actually a jemalloc-sys bug and fixed in main branch of them, but not yet released: https://github.com/tikv/jemallocator/commit/b913c24fdd4841bb4028a00207dfeb76832c806b