Skip to content

Unable to build 1.74.0 against musl #352

Closed
@lrvick

Description

@lrvick

So in #324 we were able to get musl builds working for 1.54 and this has been working in production for https://codeberg.org/stagex/stagex to produce our rust images for almost a year now.

https://codeberg.org/stagex/stagex/src/branch/main/packages/core/rust/Containerfile

In 1.74.0 using the same pattern fails:

https://codeberg.org/stagex/stagex/src/branch/lance/update-mrustc/packages/core/rust/Containerfile

#77 6814.0    Compiling fluent-syntax v0.11.0                                                       
#77 6814.0      Running `/mrustc-0.11.2/run_rustc/rustc_proxy.sh --crate-name fluent_syntax --editio
n=2018 /mrustc-0.11.2/rustc-1.74.0-src/vendor/fluent-syntax/src/lib.rs --error-format=json --json=di
agnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C o
pt-level=3 -C embed-bitcode=no --cfg 'feature="default"' -C metadata=7326bad4f34685f8 -C extra-filen
ame=-7326bad4f34685f8 --out-dir /mrustc-0.11.2/run_rustc/output/build-rustc/x86_64-unknown-linux-mus
l/release/deps --target x86_64-unknown-linux-musl -L dependency=/mrustc-0.11.2/run_rustc/output/buil
d-rustc/x86_64-unknown-linux-musl/release/deps -L dependency=/mrustc-0.11.2/run_rustc/output/build-r
ustc/release/deps --extern thiserror=/mrustc-0.11.2/run_rustc/output/build-rustc/x86_64-unknown-linu
x-musl/release/deps/libthiserror-7cb7b9123f6c1423.rmeta --cap-lints allow -L/usr/lib -Z force-unstab
le-if-unmarked -C target-feature=-crt-static`                                                       
#77 6814.1      Running `/mrustc-0.11.2/run_rustc/rustc_proxy.sh --crate-name fluent_syntax --editio
n=2018 /mrustc-0.11.2/rustc-1.74.0-src/vendor/fluent-syntax/src/lib.rs --error-format=json --json=di
agnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C e
mbed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' -C metadata=c51255a953316588 -C ex
tra-filename=-c51255a953316588 --out-dir /mrustc-0.11.2/run_rustc/output/build-rustc/release/deps -L
 dependency=/mrustc-0.11.2/run_rustc/output/build-rustc/release/deps --extern thiserror=/mrustc-0.11
.2/run_rustc/output/build-rustc/release/deps/libthiserror-2e128310c7bac9a8.rmeta --cap-lints allow` 
#77 6814.3 Segmentation fault (core dumped)                                                         
#77 6814.3 error: could not compile `fluent-syntax` (lib)                                           
#77 6814.3                                                                                          
#77 6814.3 Caused by:                                                                               
#77 6814.3   process didn't exit successfully: `/mrustc-0.11.2/run_rustc/rustc_proxy.sh --crate-name
 fluent_syntax --edition=2018 /mrustc-0.11.2/rustc-1.74.0-src/vendor/fluent-syntax/src/lib.rs --erro
r-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-
info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' -C metadata=7326bad4
f34685f8 -C extra-filename=-7326bad4f34685f8 --out-dir /mrustc-0.11.2/run_rustc/output/build-rustc/x
86_64-unknown-linux-musl/release/deps --target x86_64-unknown-linux-musl -L dependency=/mrustc-0.11.
2/run_rustc/output/build-rustc/x86_64-unknown-linux-musl/release/deps -L dependency=/mrustc-0.11.2/r
un_rustc/output/build-rustc/release/deps --extern thiserror=/mrustc-0.11.2/run_rustc/output/build-ru
stc/x86_64-unknown-linux-musl/release/deps/libthiserror-7cb7b9123f6c1423.rmeta --cap-lints allow -L/
usr/lib -Z force-unstable-if-unmarked -C target-feature=-crt-static` (exit status: 139)             
#77 6814.3 warning: build failed, waiting for other jobs to finish...                               
#77 6814.3 Segmentation fault (core dumped)                                                         
#77 6814.3 error: could not compile `fluent-syntax` (lib)                                           
#77 6814.3                                                                                          
#77 6814.3 Caused by:                                                                               
#77 6814.3   process didn't exit successfully: `/mrustc-0.11.2/run_rustc/rustc_proxy.sh --crate-name
 fluent_syntax --edition=2018 /mrustc-0.11.2/rustc-1.74.0-src/vendor/fluent-syntax/src/lib.rs --erro
r-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-
info,metadata,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' -C metadata
=c51255a953316588 -C extra-filename=-c51255a953316588 --out-dir /mrustc-0.11.2/run_rustc/output/buil
d-rustc/release/deps -L dependency=/mrustc-0.11.2/run_rustc/output/build-rustc/release/deps --extern
 thiserror=/mrustc-0.11.2/run_rustc/output/build-rustc/release/deps/libthiserror-2e128310c7bac9a8.rm
eta --cap-lints allow` (exit status: 139)  

To get it to build this far at all, we needed to apply a patch to fix lib linking for musl:
lrvick@372be71

In order to make testing/debugging with musl (or any other libc/environment) easy in-place in the mrustc repo I added an OCI shell/build harness in my branch:

https://github.com/lrvick/mrustc/blob/master/Makefile#L149-L181
https://github.com/lrvick/mrustc/blob/master/Containerfile

Provided you have docker installed, In my branch you can do:

make oci-shell

That will pivot your current working directory inside a x86_64-linux-musl shell generated by the Containerfile.

From there, you can run:

build-mrustc

To run the mrustc builder in the isolated/controlled musl environment until it fails, exactly as above.

You can shortcut to this without a shell using just make oci-build

From there any usual debugging methods are on the table inside or outside of the container.

Ideas welcome on debugging tactics!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions