Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build against musl #324

Open
lrvick opened this issue Nov 22, 2023 · 29 comments
Open

Unable to build against musl #324

lrvick opened this issue Nov 22, 2023 · 29 comments

Comments

@lrvick
Copy link
Contributor

lrvick commented Nov 22, 2023

Unable to bootstrap 1.54 from musl or glibc based linux distributions.

musl (alpine)

Repeated with master, and v0.10.1

docker run -it alpine
apk add git make gcc bash curl patch g++ zlib-dev
git clone https://github.com/thepowersgang/mrustc
cd mrustc
make -C run_rustc RUSTC_VERSION=1.54.0 RUSTC_TARGET=x86_64-unknown-linux-musl
[...]
[CXX] -o bin/mrustc
objcopy --only-keep-debug bin/mrustc bin/mrustc.debug
objcopy --add-gnu-debuglink=bin/mrustc.debug bin/mrustc
strip bin/mrustc
make[2]: Leaving directory '/mrustc'
test -e bin/mrustc
make -C tools/minicargo/
make[2]: Entering directory '/mrustc/tools/minicargo'
[CXX] main.cpp
[CXX] manifest.cpp
[CXX] repository.cpp
[CXX] cfg.cpp
[CXX] build.cpp
[CXX] jobs.cpp
[CXX] file_timestamp.cpp
[CXX] os.cpp
[CXX] -o ../../bin/minicargo
objcopy --only-keep-debug ../../bin/minicargo ../../bin/minicargo.debug
objcopy --add-gnu-debuglink=../../bin/minicargo.debug ../../bin/minicargo
strip ../../bin/minicargo
make[2]: Leaving directory '/mrustc/tools/minicargo'
test -e bin/minicargo
tar -xf rustc-1.54.0-src.tar.gz
cd rustc-1.54.0-src/ && patch -p0 < ../rustc-1.54.0-src.patch;
patching file compiler/rustc_ast/src/ast.rs
patching file compiler/rustc_hir/src/hir.rs
patching file compiler/rustc_middle/src/mir/interpret/error.rs
patching file compiler/rustc_middle/src/mir/mod.rs
patching file compiler/rustc_middle/src/thir.rs
patching file compiler/rustc_mir/src/interpret/operand.rs
patching file compiler/rustc_mir/src/interpret/place.rs
patching file library/stdarch/crates/std_detect/src/detect/mod.rs
patching file vendor/crc32fast/src/specialized/mod.rs
patching file vendor/curl/src/lib.rs
patching file vendor/ppv-lite86/src/lib.rs
patching file src/llvm-project/llvm/include/llvm/Support/Signals.h
touch rustc-1.54.0-src//dl-version
bin/minicargo --vendor-dir rustc-1.54.0-src/vendor --script-overrides script-overrides/stable-1.54.0-linux/ --output-dir output-1.54.0/ --manifest-overrides rustc-1.54.0-overrides.toml rustc-1.54.0-src/mrustc-stdlib/
--- BUILDING core v0.0.0 (0.0% 1r,0w,19b/20t)
> /mrustc/bin/mrustc rustc-1.54.0-src/library/core/src/lib.rs -o output-1.54.0/libcore.rlib -C emit-depfile=output-1.54.0/libcore.rlib.d --cfg debug_assertions -O -L output-1.54.0 --crate-name core --crate-type rlib --crate-tag 0_0_0 --edition 2018 > output-1.54.0/libcore.rlib_dbg.txt
 (0.0% 1r,0w,19b/20t): core v0.0.0
:0:0 error:0:Unknown macro {}panic/*?*/
rustc-1.54.0-src/library/core/src/num/f32.rs:1015: note: From here
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/library/core/src/lib.rs -o output-1.54.0/libcore.rlib -C emit-depfile=output-1.54.0/libcore.rlib.d --cfg debug_assertions -O -L output-1.54.0 --crate-name core --crate-type rlib --crate-tag 0_0_0 --edition 2018
Env:  OUT_DIR=/mrustc/output-1.54.0/build_core CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/library/core CARGO_PKG_NAME=core CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (5.0% 0r,0w,19b/20t):
BUILD FAILED
make[1]: *** [minicargo.mk:225: LIBS] Error 1
make[1]: Leaving directory '/mrustc'
make: *** [Makefile:125: ../output-1.54.0/rustc] Error 2
make: Leaving directory '/mrustc/run_rustc'

glibc (debian)

Repeated with master, and v0.10.1

docker run -it debian
apt update
apt install git make bash curl patch g++ zlib1g-dev
git clone https://github.com/thepowersgang/mrustc
cd mrustc
make -C run_rustc RUSTC_VERSION=1.54.0 RUSTC_TARGET=x86_64-unknown-linux-gnu
[...]
[CXX] -o bin/mrustc
objcopy --only-keep-debug bin/mrustc bin/mrustc.debug
objcopy --add-gnu-debuglink=bin/mrustc.debug bin/mrustc
strip bin/mrustc
make[2]: Leaving directory '/mrustc'
test -e bin/mrustc
make -C tools/minicargo/
make[2]: Entering directory '/mrustc/tools/minicargo'
[CXX] main.cpp
[CXX] manifest.cpp
[CXX] repository.cpp
[CXX] cfg.cpp
[CXX] build.cpp
[CXX] jobs.cpp
[CXX] file_timestamp.cpp
[CXX] os.cpp
[CXX] -o ../../bin/minicargo
objcopy --only-keep-debug ../../bin/minicargo ../../bin/minicargo.debug
objcopy --add-gnu-debuglink=../../bin/minicargo.debug ../../bin/minicargo
strip ../../bin/minicargo
make[2]: Leaving directory '/mrustc/tools/minicargo'
test -e bin/minicargo
bin/minicargo --vendor-dir rustc-1.54.0-src/vendor --script-overrides script-overrides/stable-1.54.0-linux/ --output-dir output-1.54.0/ --manifest-overrides rustc-1.54.0-overrides.toml rustc-1.54.0-src/mrustc-stdlib/
--- BUILDING core v0.0.0 (0.0% 1r,0w,19b/20t)
> /mrustc/bin/mrustc rustc-1.54.0-src/library/core/src/lib.rs -o output-1.54.0/libcore.rlib -C emit-depfile=output-1.54.0/libcore.rlib.d --cfg debug_assertions -O -L output-1.54.0 --crate-name core --crate-type rlib --crate-tag 0_0_0 --edition 2018 > output-1.54.0/libcore.rlib_dbg.txt
 (0.0% 1r,0w,19b/20t): core v0.0.0
:0:0 error:0:Unknown macro {}panic/*?*/
rustc-1.54.0-src/library/core/src/num/f32.rs:1015: note: From here
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/library/core/src/lib.rs -o output-1.54.0/libcore.rlib -C emit-depfile=output-1.54.0/libcore.rlib.d --cfg debug_assertions -O -L output-1.54.0 --crate-name core --crate-type rlib --crate-tag 0_0_0 --edition 2018
Env:  OUT_DIR=/mrustc/output-1.54.0/build_core CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/library/core CARGO_PKG_NAME=core CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (5.0% 0r,0w,19b/20t):
BUILD FAILED
make[1]: *** [minicargo.mk:225: LIBS] Error 1
make[1]: Leaving directory '/mrustc'
make: *** [Makefile:125: ../output-1.54.0/rustc] Error 2
make: Leaving directory '/mrustc/run_rustc'
@lrvick lrvick changed the title Unable to build against musl Unable to build against musl or glibc Nov 22, 2023
@thepowersgang
Copy link
Owner

See build-1.54.0.sh - You also need to set MRUSTC_TARGET_VER=1.54

@lrvick
Copy link
Contributor Author

lrvick commented Nov 23, 2023

@thepowersgang

Emulating the approach there, I get a similar macro error:

export RUSTC_VERSION=1.54.0 RUSTC_TARGET=x86_64-unknown-linux-musl MRUSTC_TARGET_VER=1.54
make
make RUSTCSRC
make -f minicargo.mk
[...]
(116/175) BUILDING rls_span from rls-span v0.5.3 with features [derive]
> /mrustc/bin/mrustc rustc-1.54.0-src/vendor/rls-span/src/lib.rs -o output-1.54.0/rustc-build/librls_span-0_5_3_H1.rlib --crate-name rls_span --crate-type rlib -C emit-depfile=output-1.54.0/rustc-build/librls_span-0_5_3_H1.rlib.d --crate-tag 0_5_3_H1 --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --cfg feature="derive" --edition 2018 --extern serde=output-1.54.0/rustc-build/libserde-1_0_126_H1a.rlib
memory allocation of 34772536320 bytes failed
TTStream:0: error:0:proc_macro derive failed
rustc-1.54.0-src/vendor/rls-span/src/compiler.rs:11: note: From here
Process was terminated with signal 6
FAILING COMMAND:  /mrustc/bin/mrustc rustc-1.54.0-src/vendor/rls-span/src/lib.rs -o output-1.54.0/rustc-build/librls_span-0_5_3_H1.rlib --crate-name rls_span --crate-type rlib -C emit-depfile=output-1.54.0/rustc-build/librls_span-0_5_3_H1.rlib.d --crate-tag 0_5_3_H1 --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --cfg feature="derive" --edition 2018 --extern serde=output-1.54.0/rustc-build/libserde-1_0_126_H1a.rlib
BUILD FAILED
make: *** [minicargo.mk:229: output-1.54.0/rustc] Error 1

@lrvick
Copy link
Contributor Author

lrvick commented Nov 23, 2023

Oh. I can't read. Ran out of memory. Ha!

@lrvick
Copy link
Contributor Author

lrvick commented Nov 23, 2023

Okay, now I think I hit an actual failure on master

export RUSTC_VERSION=1.54.0 RUSTC_TARGET=x86_64-unknown-linux-musl MRUSTC_TARGET_VER=1.54
make
make RUSTCSRC
make -f minicargo.mk
[...]
--- BUILDING rustc_index v0.0.0 (73.7% 1r,4w,56b/232t)
> /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin > output-1.54.0/rustc-build/librustc_index.rlib_dbg.txt
 (73.7% 1r,4w,56b/232t): rustc_index v0.0.0
thread 'main' panicked at 'Was not passed a macro name', :0:0
rustc-1.54.0-src/compiler/rustc_index/src/bit_set.rs:30:10-47 error:0:proc_macro derive failed
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin
Env:  OUT_DIR=/mrustc/output-1.54.0/rustc-build/build_rustc_index CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/compiler/rustc_index CARGO_PKG_NAME=rustc_index CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (74.1% 0r,4w,56b/232t):
BUILD FAILED
make: *** [minicargo.mk:256: output-1.54.0/rustc] Error 1

@thepowersgang
Copy link
Owner

That's a curious crash, can you run with MRUSTC_DEBUG=Expand and see if the debug log shows anything strange?
Maybe set MRUSTC_DUMP_PROCMACRO=dump_prefix and see if you can invoke the macro executable directly

@lrvick
Copy link
Contributor Author

lrvick commented Nov 25, 2023

Switched to a Dockerfile for testing, so it should be easy for you to reproduce if you like.

FROM alpine

RUN apk add git make gcc bash curl patch g++ zlib-dev cmake python3
RUN git clone https://github.com/thepowersgang/mrustc
WORKDIR mrustc
ENV MRUSTC_TARGET_VER=1.54
ENV RUSTC_VERSION=1.54.0
ENV RUSTC_TARGET=x86_64-unknown-linux-musl
ENV MRUSTC_DUMP_PROCMACRO=dump_prefix
ENV MRUSTC_DEBUG=Expand
RUN make
RUN make RUSTCSRC
RUN make -f minicargo.mk LIBS
RUN make test
RUN make local_tests
RUN RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/rustc
RUN RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/cargo
RUN ./output-1.54.0/rustc --version
RUN ./output-1.54.0/cargo --version

This includes your tests, a few of which fail:

make[2]: Leaving directory '/mrustc/tools/testrunner'
./bin/testrunner -o output-1.54.0/local_tests -L output-1.54.0 samples/test
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/box_free.exe samples/test/box_free.rs
Calling output-1.54.0/local_tests/box_free.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/enums.exe samples/test/enums.rs
Calling output-1.54.0/local_tests/enums.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/for_underscore_drop.exe samples/test/for_underscore_drop.rs --test
Calling output-1.54.0/local_tests/for_underscore_drop.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/funny_hash.exe samples/test/funny_hash.rs
Calling output-1.54.0/local_tests/funny_hash.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/gcc5_codegen_bug.exe samples/test/gcc5_codegen_bug.rs -O
Calling output-1.54.0/local_tests/gcc5_codegen_bug.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/i128.exe samples/test/i128.rs --test
Calling output-1.54.0/local_tests/i128.exe
DEBUG: output-1.54.0/local_tests/i128.exe was terminated with signal 11
DEBUG: RUN FAIL i128
DEBUG: - Output in output-1.54.0/local_tests/i128.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/i128_parse.exe samples/test/i128_parse.rs --test
Calling output-1.54.0/local_tests/i128_parse.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/inline_copy_values.exe samples/test/inline_copy_values.rs --test
Calling output-1.54.0/local_tests/inline_copy_values.exe
DEBUG: output-1.54.0/local_tests/inline_copy_values.exe was terminated with signal 6
DEBUG: RUN FAIL inline_copy_values
DEBUG: - Output in output-1.54.0/local_tests/inline_copy_values.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/issue-mrustc-103.exe samples/test/issue-mrustc-103.rs
Calling output-1.54.0/local_tests/issue-mrustc-103.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/issue-mrustc-107.exe samples/test/issue-mrustc-107.rs
Calling output-1.54.0/local_tests/issue-mrustc-107.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/issue-mrustc-167.exe samples/test/issue-mrustc-167.rs
Calling output-1.54.0/local_tests/issue-mrustc-167.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/issue-mrustc-62.exe samples/test/issue-mrustc-62.rs
Calling output-1.54.0/local_tests/issue-mrustc-62.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/match-deref-box-and-diverge.exe samples/test/match-deref-box-and-diverge.rs --test
Calling output-1.54.0/local_tests/match-deref-box-and-diverge.exe
DEBUG: output-1.54.0/local_tests/match-deref-box-and-diverge.exe was terminated with signal 6
DEBUG: RUN FAIL match-deref-box-and-diverge
DEBUG: - Output in output-1.54.0/local_tests/match-deref-box-and-diverge.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/match-guard-move.exe samples/test/match-guard-move.rs --test
Calling output-1.54.0/local_tests/match-guard-move.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/match-guards.exe samples/test/match-guards.rs --test
Calling output-1.54.0/local_tests/match-guards.exe
DEBUG: output-1.54.0/local_tests/match-guards.exe was terminated with signal 11
DEBUG: RUN FAIL match-guards
DEBUG: - Output in output-1.54.0/local_tests/match-guards.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/misc_macro_issues.exe samples/test/misc_macro_issues.rs --test
Calling output-1.54.0/local_tests/misc_macro_issues.exe
DEBUG: output-1.54.0/local_tests/misc_macro_issues.exe was terminated with signal 6
DEBUG: RUN FAIL misc_macro_issues
DEBUG: - Output in output-1.54.0/local_tests/misc_macro_issues.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/mrustc-274.exe samples/test/mrustc-274.rs
Calling output-1.54.0/local_tests/mrustc-274.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/mrustc-275.exe samples/test/mrustc-275.rs
Calling output-1.54.0/local_tests/mrustc-275.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/mrustc-318.exe samples/test/mrustc-318.rs
Calling output-1.54.0/local_tests/mrustc-318.exe
DEBUG: output-1.54.0/local_tests/mrustc-318.exe was terminated with signal 11
DEBUG: RUN FAIL mrustc-318
DEBUG: - Output in output-1.54.0/local_tests/mrustc-318.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/mrustc-issue-267.exe samples/test/mrustc-issue-267.rs
Calling output-1.54.0/local_tests/mrustc-issue-267.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/mrustc_271.exe samples/test/mrustc_271.rs
Calling output-1.54.0/local_tests/mrustc_271.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/scoping_rules.exe samples/test/scoping_rules.rs --test
Calling output-1.54.0/local_tests/scoping_rules.exe
DEBUG: output-1.54.0/local_tests/scoping_rules.exe was terminated with signal 6
DEBUG: RUN FAIL scoping_rules
DEBUG: - Output in output-1.54.0/local_tests/scoping_rules.out_failed
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/thread_drop.exe samples/test/thread_drop.rs
Calling output-1.54.0/local_tests/thread_drop.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/vec_retain.exe samples/test/vec_retain.rs
Calling output-1.54.0/local_tests/vec_retain.exe
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/zst_use.exe samples/test/zst_use.rs --test
Calling output-1.54.0/local_tests/zst_use.exe
DEBUG: output-1.54.0/local_tests/zst_use.exe was terminated with signal 11
DEBUG: RUN FAIL zst_use
DEBUG: - Output in output-1.54.0/local_tests/zst_use.out_failed
TESTS COMPLETED
17 passed, 8 failed, 0 errored, 0 skipped
make[1]: Leaving directory '/mrustc'
make[1]: *** [minicargo.mk:355: local_tests] Error 1
make: *** [Makefile:153: local_tests] Error 2
The command '/bin/sh -c make local_tests' returned a non-zero code: 2

If I comment out the test lines and let it keep building I get:

--- BUILDING rustc_index v0.0.0 (73.7% 1r,4w,56b/232t)
> /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin > output-1.54.0/rustc-build/librustc_index.rlib_dbg.txt
 (73.7% 1r,4w,56b/232t): rustc_index v0.0.0
memory allocation of 43487284224 bytes failed
rustc-1.54.0-src/compiler/rustc_index/src/bit_set.rs:30:10-47 error:0:proc_macro derive failed
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin
Env:  OUT_DIR=/mrustc/output-1.54.0/rustc-build/build_rustc_index CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/compiler/rustc_index CARGO_PKG_NAME=rustc_index CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (74.1% 0r,4w,56b/232t):
BUILD FAILED
make: *** [minicargo.mk:256: output-1.54.0/rustc] Error 1
The command '/bin/sh -c RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/rustc' returned a non-zero code: 2

@thepowersgang
Copy link
Owner

That's another out-of-memory error.
From your original failure, look at the end of output-1.54.0/rustc-build/librustc_index.rlib_dbg.txt (after setting those two environment variables)

@thepowersgang
Copy link
Owner

Now that I'm more awake - the failing tests may be linked to the issue, plus that OOM is for a massive byte count (~40GB)

@lrvick
Copy link
Contributor Author

lrvick commented Nov 26, 2023

I was able to get a successful build from the following debian dockerfile with 15G of memory assigned to the building VM:

FROM debian:bookworm

RUN set -eux; \
    apt update; \
    apt install -y \
        git make gcc bash curl patch g++ zlib1g-dev cmake python3
RUN git clone https://github.com/thepowersgang/mrustc
WORKDIR mrustc
ENV MRUSTC_TARGET_VER=1.54
ENV RUSTC_VERSION=1.54.0
ENV RUSTC_TARGET=x86_64-unknown-linux-musl
ENV MRUSTC_DUMP_PROCMACRO=dump_prefix
ENV MRUSTC_DEBUG=Expand
RUN make
RUN make RUSTCSRC
RUN make -f minicargo.mk LIBS
RUN make test
RUN make local_tests
RUN RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/rustc
RUN RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/cargo
RUN ./output-1.54.0/rustc --version
RUN ./output-1.54.0/cargo --version

However, building with the last alpine dockerfile I posted earlier (which is almost identical to the debian one) I still get the same build error in the same spot, even with 30GB of memory available.

Going to give it more ram and try again.

@thepowersgang
Copy link
Owner

It shouldn't need that much. I've installed docker and reproduced the error, although it seems inconsistent.
I do normal builds on a 16GB machine with 4-6 jobs - peak memory usage should be lower than 10GB (for librustc, which is an absolute chonk).

@thepowersgang
Copy link
Owner

thepowersgang commented Nov 26, 2023

Output from doing a manual run to debug/diagnose. Seems like there's some nondeterministic behavior in the generated code.

...
Calling mrustc -O -g -L output-1.54.0 -o output-1.54.0/local_tests/zst_use.exe samples/test/zst_use.rs --test
Calling output-1.54.0/local_tests/zst_use.exe
DEBUG: output-1.54.0/local_tests/zst_use.exe was terminated with signal 6
DEBUG: RUN FAIL zst_use
DEBUG: - Output in output-1.54.0/local_tests/zst_use.out_failed
TESTS COMPLETED
19 passed, 6 failed, 0 errored, 0 skipped
make: *** [minicargo.mk:355: local_tests] Error 1
39beea96a250:/mrustc# ./output-1.54.0/local_tests/zst_use.exe

running 1 test
test ::zst_enum_variant ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

39beea96a250:/mrustc# 

@thepowersgang
Copy link
Owner

This might be an error in the -musl target support (not being passed through to libstd correctly?)
In fact, mrustc is not able to detect/support -musl targets, it defaults to building for -gnu

@lrvick
Copy link
Contributor Author

lrvick commented Nov 27, 2023

I have the VM assigned 20 cores, which might explain the high ram usage due to the number of jobs.

Increasing ram to 45G and I am at least able to get through to the error without obvious memory allocation failures:

--- BUILDING rustc_index v0.0.0 (73.7% 1r,4w,56b/232t)
> /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin > output-1.54.0/rustc-build/librustc_index.rlib_dbg.txt
 (73.7% 1r,4w,56b/232t): rustc_index v0.0.0
thread 'main' panicked at 'Was not passed a macro name', :0:0
rustc-1.54.0-src/compiler/rustc_index/src/bit_set.rs:30:10-47 error:0:proc_macro derive failed
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin
Env:  OUT_DIR=/mrustc/output-1.54.0/rustc-build/build_rustc_index CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/compiler/rustc_index CARGO_PKG_NAME=rustc_index CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (74.1% 0r,4w,56b/232t):
BUILD FAILED
make: *** [minicargo.mk:256: output-1.54.0/rustc] Error 1
The command '/bin/sh -c RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/rustc' returned a non-zero code: 2

As for your theory about -musl target, I mistakenly had -musl set in my debian dockerfile above, and that built just fine.

That would indicate to me that there is a hard expectation on the system libc being glibc somewhere.

Everything in alpine and the distro I am working on is linked against musl, so clobbering the global default libc paths would break things.

Do you know of a global way to specify an alternate libc search path that will work with your whole build chain so I can feed it a one-off built glibc?

It would mean of course the resulting rustc 1.54 binary will be linked against glibc, though it should in theory be able to produce newer versions of rust linked against musl normally, I think.

@lrvick
Copy link
Contributor Author

lrvick commented Nov 27, 2023

Yeah, just did a build in alpine with "RUSTC_TARGET=x86_64-unknown-linux-gnu" and same issue:

--- BUILDING rustc_index v0.0.0 (73.7% 1r,4w,56b/232t)
> /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin > output-1.54.0/rustc-build/librustc_index.rlib_dbg.txt
 (73.7% 0r,4w,57b/232t):
 (73.7% 1r,4w,56b/232t): rustc_index v0.0.0
rustc-1.54.0-src/compiler/rustc_index/src/bit_set.rs:30:10-47 error:0:proc_macro derive failed
Process was terminated with signal 6
FAILING COMMAND: /mrustc/bin/mrustc rustc-1.54.0-src/compiler/rustc_index/src/lib.rs -o output-1.54.0/rustc-build/librustc_index.rlib -C emit-depfile=output-1.54.0/rustc-build/librustc_index.rlib.d --cfg debug_assertions -O -L output-1.54.0 -L output-1.54.0/rustc-build --crate-name rustc_index --crate-type rlib --crate-tag 0_0_0 --edition 2018 --extern arrayvec=output-1.54.0/rustc-build/libarrayvec-0_7_0.rlib --extern rustc_serialize=output-1.54.0/rustc-build/librustc_serialize.rlib --extern rustc_macros=output-1.54.0/rustc-build/librustc_macros-0_1_0-plugin
Env:  OUT_DIR=/mrustc/output-1.54.0/rustc-build/build_rustc_index CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/compiler/rustc_index CARGO_PKG_NAME=rustc_index CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (74.1% 0r,4w,56b/232t):
BUILD FAILED
make: *** [minicargo.mk:256: output-1.54.0/rustc] Error 1
The command '/bin/sh -c RUSTC_INSTALL_BINDIR=bin make -f minicargo.mk output-1.54.0/rustc' returned a non-zero code: 2

Something is incompatible with the system libc being musl.

Am going to try packaging glibc then try to build only mrustc C++ binaries against it and see if the rest holds with musl.

@thepowersgang
Copy link
Owner

Yes. libstd is being told that the system libc is glibc (see tools/common/target_detect.hpp and src/trans/target.cpp) - so it generates code that assumes glibc's quirks and thus doesn't correctly run with musl

@lrvick
Copy link
Contributor Author

lrvick commented Nov 27, 2023

Ah! That makes sense. I'll try adjusting those and see if I can get it working, then submit a PR if so.

@thepowersgang
Copy link
Owner

If you get it working, a PR would be appreciated.
Bonus points if you can set up CI for it :)

@lrvick lrvick changed the title Unable to build against musl or glibc Unable to build against musl Nov 28, 2023
@lrvick lrvick mentioned this issue Nov 28, 2023
@lrvick
Copy link
Contributor Author

lrvick commented Dec 4, 2023

@thepowersgang

Thanks for the merge.

Was able to build with shared llvm13 using the LLVM_CONFIG variable.

When I went to actually use the rustc and cargo to build the next version of rust however, I realized I had not actually built libstd and friends in run_rustc yet, so what we merged is just a partial solution.

Run_rustc failed pretty early due to the hardcoding of x86_64-unknown-gnu in run_rustc/Makefile.

I corrected this with the following patch:

diff --git a/run_rustc/Makefile b/run_rustc/Makefile
index 308f0331..09d10597 100644
--- a/run_rustc/Makefile
+++ b/run_rustc/Makefile
@@ -35,6 +35,10 @@ ifeq ($(shell uname -s || echo not),Darwin)
   DYLIB_EXT := dylib
   PLATFORM := macos
   RUSTC_TARGET ?= x86_64-apple-darwin
+else ifeq($(shell ldd ../bin/minicargo | grep -q musl && echo -n "yes"),yes)
+  DYLIB_EXT := so
+  PLATFORM := linux
+  RUSTC_TARGET ?= x86_64-unknown-linux-musl
 else
   DYLIB_EXT := so
   PLATFORM := linux
@@ -105,7 +109,7 @@ CARGO_FLAGS := --target $(RUSTC_TARGET) -j $(PARLEVEL) --release --verbose
 CARGO_ENV := CFG_COMPILER_HOST_TRIPLE=$(RUSTC_TARGET)
 CARGO_ENV += RUSTC_BOOTSTRAP=1
 CARGO_ENV += CARGO_HOME=$(CARGO_HOME)
-CARGO_ENV += RUSTFLAGS="-Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$$ORIGIN/../lib"
+CARGO_ENV += RUSTFLAGS="-L/usr/lib -Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$$ORIGIN/../lib"
 
 fn_opt_copy = (test -e "$2" && test ! "$1" -nt "$2") || cp "$1" "$2"

This allowed me to get a lot further, but a new build failure which seems like some sort of path issue still, though I can't see any more hadcoded -gnu references.

Been debugging this a while so another set of eyes would be welcome, as I don't fully understand all the custom stage paths and when they are used yet.

make
make RUSTCSRC
rm -rf rustc-1.54.0-src/src/llvm-project
make -f minicargo.mk LIBS
make test local_tests
make -f minicargo.mk LLVM_CONFIG=/usr/bin/llvm-config output/rustc
make -f minicargo.mk LLVM_CONFIG=/usr/bin/llvm-config output/cargo
## All of the above works, and produces cargo/rustc binaries that can --version

make -d -C run_rustc LLVM_CONFIG=/usr/bin/llvm-config
[...]
      Must remake target 'output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib'.
Makefile:173: update target 'output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib' due to: output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd.rlib output/prefix-2/bin/rustc output/prefix-s/bin/rustc output/prefix/bin/cargo output/prefix/cargo_home/config Makefile
mkdir -p output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/
Putting child 0x7cc4e7c63b40 (output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib) PID 8671 on the chain.
Live child 0x7cc4e7c63b40 (output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib) PID 8671 
Reaping winning child 0x7cc4e7c63b40 PID 8671 
echo [CARGO] ../rustc-1.54.0-src/library/test/Cargo.toml '>' output/build-std2
Live child 0x7cc4e7c63b40 (output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib) PID 8672 
[CARGO] ../rustc-1.54.0-src/library/test/Cargo.toml > output/build-std2
Reaping winning child 0x7cc4e7c63b40 PID 8672 
CARGO_TARGET_DIR=output/build-std2 RUSTC=/home/user/mrustc/run_rustc/rustc_proxy.sh PROXY_RUSTC=/home/user/mrustc/run_rustc/output/prefix-2/bin/rustc PROXY_MRUSTC=/home/user/mrustc/run_rustc/output/prefix-s/bin/rustc CFG_COMPILER_HOST_TRIPLE=x86_64-unknown-linux-musl RUSTC_BOOTSTRAP=1 CARGO_HOME=output/prefix/cargo_home/ RUSTFLAGS="-L/usr/lib -Z force-unstable-if-unmarked -C link_args=-Wl,-rpath,\$ORIGIN/../lib" output/prefix/bin/cargo build --target x86_64-unknown-linux-musl -j 1 --release --verbose --manifest-path ../rustc-1.54.0-src/library/test/Cargo.toml --features panic-unwind
Live child 0x7cc4e7c63b40 (output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib) PID 8673 
   Compiling compiler_builtins v0.1.45
     Running `/home/user/mrustc/run_rustc/rustc_proxy.sh --crate-name build_script_build /home/user/mrustc/rustc-1.54.0-src/vendor/compiler_builtins/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C codegen-units=10000 -C debug-assertions=off --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=2b025b47c8354f2c -C extra-filename=-2b025b47c8354f2c --out-dir /home/user/mrustc/run_rustc/output/build-std2/release/build/compiler_builtins-2b025b47c8354f2c -L dependency=/home/user/mrustc/run_rustc/output/build-std2/release/deps --cap-lints allow`
error[E0463]: can't find crate for `std`

Aborted (core dumped)
error: could not compile `compiler_builtins`

Caused by:
  process didn't exit successfully: `/home/user/mrustc/run_rustc/rustc_proxy.sh --crate-name build_script_build /home/user/mrustc/rustc-1.54.0-src/vendor/compiler_builtins/build.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C codegen-units=10000 -C debug-assertions=off --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=2b025b47c8354f2c -C extra-filename=-2b025b47c8354f2c --out-dir /home/user/mrustc/run_rustc/output/build-std2/release/build/compiler_builtins-2b025b47c8354f2c -L dependency=/home/user/mrustc/run_rustc/output/build-std2/release/deps --cap-lints allow` (exit status: 134)
Reaping losing child 0x7cc4e7c63b40 PID 8673 
make: *** [Makefile:175: output/prefix-2/lib/rustlib/x86_64-unknown-linux-musl/lib/libtest.rlib] Error 101
Removing child 0x7cc4e7c63b40 PID 8673 from chain.
make: Leaving directory '/home/user/mrustc/run_rustc'

@lrvick
Copy link
Contributor Author

lrvick commented Dec 4, 2023

Attaching a full build log of the above.
run_rustc_musl_build-failure.log

@thepowersgang
Copy link
Owner

Pruning file 'output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd.rlib'. Looks like make was being "nice" and deleting an intermediate file that it shouldn't have

@lrvick
Copy link
Contributor Author

lrvick commented Dec 4, 2023

@thepowersgang Am I doing something in an unexpected order to cause that to happen?

I am having a hard time finding much information on how make makes pruning decisions.

@lrvick
Copy link
Contributor Author

lrvick commented Dec 5, 2023

Went back to Alpine as a better understood control case using the following dockerfile:

FROM alpine:3.16

RUN apk add git make gcc bash curl patch g++ zlib-dev cmake python3 llvm13 llvm13-dev llvm13-libs llvm13-static libxml2-dev openssl-dev perl
RUN git clone https://github.com/lrvick/mrustc
WORKDIR mrustc
ENV MRUSTC_TARGET_VER=1.54
ENV RUSTC_VERSION=1.54.0
ENV RUSTC_TARGET=x86_64-unknown-linux-musl
ENV RUSTC_INSTALL_BINDIR=bin
ENV MRUSTC_DUMP_PROCMACRO=dump_prefix
ENV MRUSTC_DEBUG=Expand
ENV OUTDIR_SUF=
RUN make
RUN make RUSTCSRC
RUN rm -rf rustc-1.54.0-src/src/llvm-project
RUN make -f minicargo.mk LIBS
RUN make test
RUN make local_tests
RUN make -f minicargo.mk LLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config output/rustc
RUN make -f minicargo.mk LLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config output/cargo
RUN ./output/rustc --version
RUN ./output/cargo --version
RUN make -C run_rustc LLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config

Failed in a way I have never seen rust fail:

/mrustc # make -C run_rustc LLVM_CONFIG=/usr/lib/llvm13/bin/llvm-config
make: Entering directory '/mrustc/run_rustc'
[MINICARGO] ../rustc-1.54.0-src/library/std > output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/
mkdir -p output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/
--- BUILDING core v0.0.0 (0.0% 1r,0w,12b/13t)
> /mrustc/run_rustc/output/prefix-s/bin/rustc ../rustc-1.54.0-src/library/core/src/lib.rs -o output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib --emit link,dep-info --cfg debug_assertions -O -L output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib --crate-name core --crate-type rlib -C metadata=0_0_0 --edition 2018 > output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib_dbg.txt
 (0.0% 1r,0w,12b/13t): core v0.0.0
warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type

thread 'rustc' panicked at 'Failed to get crate data for crate2853', :0:0

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-stable-mrustc running on x86_64-unknown-linux-musl

note: compiler flags: --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
thread 'rustc' panicked at 'Failed to get crate data for crate2853', :0:0
stack backtrace:
   0:     0x5627a9f956d6 - <unknown>
   1:     0x5627a9f673da - <unknown>
   2:     0x5627a9f7fe26 - <unknown>
   3:     0x5627a9f8b96b - <unknown>
   4:     0x5627a9fa5af4 - <unknown>
   5:     0x5627a9fa5c67 - <unknown>
   6:     0x5627a9fa6ab4 - <unknown>
   7:     0x5627ac74d70e - <unknown>
   8:     0x5627a9fa8639 - <unknown>
   9:     0x5627a9fa8943 - <unknown>
  10:     0x5627a9fa89ae - <unknown>
  11:     0x5627a9fa8a72 - <unknown>
  12:     0x5627aad782f5 - <unknown>
  13:     0x5627aad7836e - <unknown>
  14:     0x5627aade0451 - <unknown>
  15:     0x5627aa44dc39 - <unknown>
  16:     0x5627aa5c3bc0 - <unknown>
  17:     0x5627aa5c3e9b - <unknown>
  18:     0x5627abd69114 - <unknown>
  19:     0x5627abd69253 - <unknown>
  20:     0x5627abd69362 - <unknown>
  21:     0x5627abb62c7a - <unknown>
  22:     0x5627abe69b54 - <unknown>
  23:     0x5627abec0b36 - <unknown>
  24:     0x5627ac5b914a - <unknown>
  25:     0x5627ac74dc95 - <unknown>
  26:     0x5627a9fa8639 - <unknown>
  27:     0x5627a9fa8943 - <unknown>
  28:     0x5627a9fa89ae - <unknown>
  29:     0x5627a9fa8a72 - <unknown>
  30:     0x5627aad782f5 - <unknown>
  31:     0x5627aad7836e - <unknown>
  32:     0x5627aae3d1ce - <unknown>
  33:     0x5627ab87402d - <unknown>
  34:     0x5627ab8fa026 - <unknown>
  35:     0x5627ab8fa0a4 - <unknown>
  36:     0x5627ab8fa1aa - <unknown>
  37:     0x5627ab8fa269 - <unknown>
  38:     0x5627abe81c37 - <unknown>
  39:     0x5627abe82018 - <unknown>
  40:     0x5627abe822f5 - <unknown>
  41:     0x5627aa7d6344 - <unknown>
  42:     0x5627aa87fc68 - <unknown>
  43:     0x5627aa9835ce - <unknown>
  44:     0x5627aa98369f - <unknown>
  45:     0x5627aa9a960e - <unknown>
  46:     0x5627aa9a9b28 - <unknown>
  47:     0x5627aa9a9c9d - <unknown>
  48:     0x5627aa9aa54e - <unknown>
  49:     0x5627aa9aadb3 - <unknown>
  50:     0x5627ac4f625f - <unknown>
  51:     0x5627ac4f7321 - <unknown>
  52:     0x5627ab86fe0c - <unknown>
  53:     0x5627ab89038a - <unknown>
  54:     0x5627ab8e3c82 - <unknown>
  55:     0x5627ab8f0a9f - <unknown>
  56:     0x5627abee40a3 - <unknown>
  57:     0x5627aa8f9cad - <unknown>
  58:     0x5627aa9b836d - <unknown>
  59:     0x5627aa9b9ef7 - <unknown>
  60:     0x5627ac11e6d0 - <unknown>
  61:     0x5627ac1f0021 - <unknown>
  62:     0x5627ac1f016f - <unknown>
  63:     0x5627ac1f0436 - <unknown>
  64:     0x5627ac1f0529 - <unknown>
  65:     0x5627ac1f065f - <unknown>
  66:     0x5627ac231595 - <unknown>
  67:     0x5627ab86c9f1 - <unknown>
  68:     0x5627ab8d7807 - <unknown>
  69:     0x5627ab8ee1ac - <unknown>
  70:     0x5627abe70262 - <unknown>
  71:     0x5627abe737ee - <unknown>
  72:     0x5627ac1751e7 - <unknown>
  73:     0x5627ac1779ac - <unknown>
  74:     0x5627ac177aea - <unknown>
  75:     0x5627ac177d05 - <unknown>
  76:     0x5627ac178285 - <unknown>
  77:     0x5627ac2a78b6 - <unknown>
  78:     0x5627ac5bc043 - <unknown>
  79:     0x5627ab86c5ce - <unknown>
  80:     0x5627ab8e3d01 - <unknown>
  81:     0x5627ab8e3da4 - <unknown>
  82:     0x5627abf66ed7 - <unknown>
  83:     0x5627ac65f2e5 - <unknown>
  84:     0x5627ac74b7be - <unknown>
  85:     0x5627ac753050 - <unknown>
  86:     0x5627ac75336e - <unknown>
  87:     0x5627ac75609b - <unknown>
  88:     0x5627ac756da3 - <unknown>
  89:     0x5627ac7571e3 - <unknown>
  90:     0x5627ac7572d0 - <unknown>
  91:     0x5627a9fa3b7e - <unknown>
  92:     0x7ff4b769d1d9 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.54.0-stable-mrustc running on x86_64-unknown-linux-musl

note: compiler flags: --crate-type rlib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
thread panicked while panicking. aborting.
Process was terminated with signal 6
FAILING COMMAND: /mrustc/run_rustc/output/prefix-s/bin/rustc ../rustc-1.54.0-src/library/core/src/lib.rs -o output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libcore.rlib --emit link,dep-info --cfg debug_assertions -O -L output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib --crate-name core --crate-type rlib -C metadata=0_0_0 --edition 2018
Env:  OUT_DIR=/mrustc/run_rustc/output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/build_core CARGO_MANIFEST_DIR=/mrustc/rustc-1.54.0-src/library/core CARGO_PKG_NAME=core CARGO_PKG_VERSION=0.0.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0
 (7.7% 0r,0w,12b/13t):
BUILD FAILED
make: *** [Makefile:162: output/prefix-s/lib/rustlib/x86_64-unknown-linux-musl/lib/libstd.rlib] Error 1
make: Leaving directory '/mrustc/run_rustc'

@lrvick lrvick closed this as completed Dec 5, 2023
@lrvick lrvick reopened this Dec 5, 2023
@lrvick
Copy link
Contributor Author

lrvick commented Dec 5, 2023

Possibly relevant issue: rust-cross/rust-musl-cross#37

@lrvick
Copy link
Contributor Author

lrvick commented Dec 8, 2023

Okay! With a few hacks in my branch (that will take some work to clean-up so as not to break other targets) I was able to get run_rustc to run to completion with musl, and get hello_world.

The full mrustc docker bootstrap build setup here generates a rust 1.54 container.

I then try to use that container to bootstrap rust 1.55 as follows:

FROM busybox as rust1.55
ENV SRC_SITE=https://codeload.github.com/rust-lang/rust/legacy.tar.gz
ENV SRC_VERSION=c8dfcfe046a7680554bf4eb612bad840e7631c4b
ENV SRC_HASH=59ce21c1ef59ad32fc63d7f7bc111e613e55a992b6f42dc64393b8cb308f76fb
ENV SRC_SITE=https://static.rust-lang.org/dist
ENV SRC_VERSION=1.55.0
ENV SRC_HASH=b2379ac710f5f876ee3c3e03122fe33098d6765d371cac6c31b1b6fc8e43821e
RUN wget ${SRC_SITE}/rustc-${SRC_VERSION}-src.tar.gz
RUN echo "${SRC_HASH}  rustc-${SRC_VERSION}-src.tar.gz" | sha256sum -c
RUN tar -xzf rustc-${SRC_VERSION}-src.tar.gz
WORKDIR rustc-${SRC_VERSION}-src
COPY disable-default-static.patch .
RUN patch -p1 < disable-default-static.patch
COPY --from=binutils . /
COPY --from=bash . /
COPY --from=make . /
COPY --from=python . /
COPY --from=py-setuptools . /
COPY --from=zlib . /
COPY --from=openssl . /
COPY --from=llvm13 . /
COPY --from=gcc . /
COPY --from=musl . /
COPY --from=rust1.54 . /
RUN set -eux; \
    ./configure \
        --build="x86_64-unknown-linux-musl" \
        --host="x86_64-unknown-linux-musl" \
        --target="x86_64-unknown-linux-musl" \
        --prefix="/usr" \
        --release-channel="stable" \
        --enable-local-rust \
        --local-rust-root="/usr" \
        --llvm-root="/usr/lib/llvm13" \
        --disable-docs \
        --tools="cargo" \
        --enable-llvm-link-shared \
        --enable-option-checking \
        --enable-locked-deps \
        --enable-vendor \
        --dist-compression-formats=gz \
        --python="python3" \
        --set="rust.musl-root=/usr" \
        --set="rust.backtrace-on-ice=true" \
        --set="rust.codegen-units=1" \
        --set="rust.codegen-units-std=1" \
        --set="rust.deny-warnings=false" \
        --set="rust.parallel-compiler=false" \
        --set="rust.remap-debuginfo=true" \
        --set="build.full-bootstrap=true" \
        --set="target.x86_64-unknown-linux-musl.crt-static=false" \
        --set="target.x86_64-unknown-linux-musl.musl-root=/usr" \
        --set="target.x86_64-unknown-linux-musl.llvm-config=/usr/bin/llvm-config" \
        --set="target.x86_64-unknown-linux-musl.cc=cc" \
        --set="target.x86_64-unknown-linux-musl.cxx=c++" \
        --set="target.x86_64-unknown-linux-musl.ar=ar" \
        --set="target.x86_64-unknown-linux-musl.linker=cc"; \
  python3 x.py build --stage 3

This however results in some build errors I don't understand as I have the full prefix from mrustc present:

Step 87/87 : RUN set -eux;     ./configure         --build="x86_64-unknown-linux-musl"         --host="x86_64-unknown-linux-musl"         --target="x86_64-unknown-linux-musl"         --prefix="/usr"         --release-channel="stable"         --enable-local-rust         --local-rust-root="/usr"         --llvm-root="/usr/lib/llvm13"         --disable-docs         --tools="cargo"         --enable-llvm-link-shared         --enable-option-checking         --enable-locked-deps         --enable-vendor         --dist-compression-formats=gz         --python="python3"         --set="rust.musl-root=/usr"         --set="rust.backtrace-on-ice=true"         --set="rust.codegen-units=1"         --set="rust.codegen-units-std=1"         --set="rust.deny-warnings=false"         --set="rust.parallel-compiler=false"         --set="rust.remap-debuginfo=true"         --set="build.full-bootstrap=true"         --set="target.x86_64-unknown-linux-musl.crt-static=false"         --set="target.x86_64-unknown-linux-musl.musl-root=/usr"         --set="target.x86_64-unknown-linux-musl.llvm-config=/usr/bin/llvm-config"         --set="target.x86_64-unknown-linux-musl.cc=cc"         --set="target.x86_64-unknown-linux-musl.cxx=c++"         --set="target.x86_64-unknown-linux-musl.ar=ar"         --set="target.x86_64-unknown-linux-musl.linker=cc";   python3 x.py build --stage 3
 ---> Running in 2d147552df97
+ ./configure '--build=x86_64-unknown-linux-musl' '--host=x86_64-unknown-linux-musl' '--target=x86_64-unknown-linux-musl' '--prefix=/usr' '--release-channel=stable' --enable-local-rust '--local-rust-root=/usr' '--llvm-root=/usr/lib/llvm13' --disable-docs '--tools=cargo' --enable-llvm-link-shared --enable-option-checking --enable-locked-deps --enable-vendor '--dist-compression-formats=gz' '--python=python3' '--set=rust.musl-root=/usr' '--set=rust.backtrace-on-ice=true' '--set=rust.codegen-units=1' '--set=rust.codegen-units-std=1' '--set=rust.deny-warnings=false' '--set=rust.parallel-compiler=false' '--set=rust.remap-debuginfo=true' '--set=build.full-bootstrap=true' '--set=target.x86_64-unknown-linux-musl.crt-static=false' '--set=target.x86_64-unknown-linux-musl.musl-root=/usr' '--set=target.x86_64-unknown-linux-musl.llvm-config=/usr/bin/llvm-config' '--set=target.x86_64-unknown-linux-musl.cc=cc' '--set=target.x86_64-unknown-linux-musl.cxx=c++' '--set=target.x86_64-unknown-linux-musl.ar=ar' '--set=target.x86_64-unknown-linux-musl.linker=cc'
configure: processing command line
configure: 
configure: build.build          := x86_64-unknown-linux-musl
configure: build.host           := ['x86_64-unknown-linux-musl']
configure: build.target         := ['x86_64-unknown-linux-musl']
configure: install.prefix       := /usr
configure: rust.channel         := stable
configure: build.rustc          := /usr/bin/rustc
configure: build.cargo          := /usr/bin/cargo
configure: build.rustc          := /usr/bin/rustc
configure: build.cargo          := /usr/bin/cargo
configure: target.x86_64-unknown-linux-musl.llvm-config := /usr/lib/llvm13/bin/ll ...
configure: build.docs           := False
configure: build.tools          := ['cargo']
configure: llvm.link-shared     := True
configure: build.locked-deps    := True
configure: build.vendor         := True
configure: dist.compression-formats := ['gz']
configure: build.python         := python3
configure: rust.musl-root       := /usr
configure: rust.backtrace-on-ice := True
configure: rust.codegen-units   := 1
configure: rust.codegen-units-std := 1
configure: rust.deny-warnings   := False
configure: rust.parallel-compiler := False
configure: rust.remap-debuginfo := True
configure: build.full-bootstrap := True
configure: target.x86_64-unknown-linux-musl.crt-static := False
configure: target.x86_64-unknown-linux-musl.musl-root := /usr
configure: target.x86_64-unknown-linux-musl.llvm-config := /usr/bin/llvm-config
configure: target.x86_64-unknown-linux-musl.cc := cc
configure: target.x86_64-unknown-linux-musl.cxx := c++
configure: target.x86_64-unknown-linux-musl.ar := ar
configure: target.x86_64-unknown-linux-musl.linker := cc
configure: build.configure-args := ['--build=x86_64-unknown-linux-musl', '--host= ...
configure: 
configure: writing `config.toml` in current directory
configure: 
configure: run `python /home/user/rustc-1.55.0-src/x.py --help`
configure: 
+ python3 x.py build --stage 3
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling syn v1.0.65
   Compiling memchr v2.4.1
   Compiling autocfg v1.0.0
   Compiling version_check v0.9.3
   Compiling lazy_static v1.4.0
   Compiling libc v0.2.93
   Compiling cfg-if v1.0.0
   Compiling serde_derive v1.0.125
error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `core`

error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `core`

error[E0463]: can't find crate for `std`

error[E0463]: can't find crate for `core`

error[E0463]: can't find crate for `std`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `autocfg`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: build failed
failed to run: /usr/bin/cargo build --manifest-path /home/user/rustc-1.55.0-src/src/bootstrap/Cargo.toml --locked --frozen
Build completed unsuccessfully in 0:00:01
The command '/bin/sh -c set -eux;     ./configure         --build="x86_64-unknown-linux-musl"         --host="x86_64-unknown-linux-musl"         --target="x86_64-unknown-linux-musl"         --prefix="/usr"         --release-channel="stable"         --enable-local-rust         --local-rust-root="/usr"         --llvm-root="/usr/lib/llvm13"         --disable-docs         --tools="cargo"         --enable-llvm-link-shared         --enable-option-checking         --enable-locked-deps         --enable-vendor         --dist-compression-formats=gz         --python="python3"         --set="rust.musl-root=/usr"         --set="rust.backtrace-on-ice=true"         --set="rust.codegen-units=1"         --set="rust.codegen-units-std=1"         --set="rust.deny-warnings=false"         --set="rust.parallel-compiler=false"         --set="rust.remap-debuginfo=true"         --set="build.full-bootstrap=true"         --set="target.x86_64-unknown-linux-musl.crt-static=false"         --set="target.x86_64-unknown-linux-musl.musl-root=/usr"         --set="target.x86_64-unknown-linux-musl.llvm-config=/usr/bin/llvm-config"         --set="target.x86_64-unknown-linux-musl.cc=cc"         --set="target.x86_64-unknown-linux-musl.cxx=c++"         --set="target.x86_64-unknown-linux-musl.ar=ar"         --set="target.x86_64-unknown-linux-musl.linker=cc";   python3 x.py build --stage 3' returned a non-zero code: 1

Any suggestions welcome!

@thepowersgang
Copy link
Owner

Did you look at TestRustcBootstrap.sh?
Is the standard library in /usr?

@lrvick
Copy link
Contributor Author

lrvick commented Dec 9, 2023

Just made some adjustments to that script for my env and made it much further at least.

On closer inspection this appears to be because I have rustlib at /lib/rustlib instead of /usr/lib/rustlib. Always something dumb like pathing that I overlook!

Anyway, this died 3 minutes in like this. On to the next level of debugging.

-- Configuring done (12.8s)
-- Generating done (3.2s)
-- Build files have been written to: /home/user/mrustc/rustc_bootstrap/build/rustc-1.55.0-src/build/x86_64-unknown-linux-musl/llvm/build
running: "cmake" "--build" "." "--target" "install" "--config" "Release" "--" "-j" "10"
[  0%] Building C object utils/count/CMakeFiles/count.dir/count.c.o
[  0%] Building CXX object utils/PerfectShuffle/CMakeFiles/llvm-PerfectShuffle.dir/PerfectShuffle.cpp.o
[  0%] Creating export file for BugpointPasses
[  0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o
[  0%] Generating VCSRevision.h
[  0%] Creating export file for LLVMHello
[  0%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmMatcherEmitter.cpp.o
[  0%] Creating export file for Remarks
[  0%] Creating export file for LTO
[  0%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/DynamicLibraryLib.dir/ExportedFuncs.cpp.o
[  0%] Built target BugpointPasses_exports
CMake Warning at /home/user/mrustc/rustc_bootstrap/build/rustc-1.55.0-src/src/llvm-project/llvm/cmake/modules/VersionFromVCS.cmake:49 (message):
  Git not found.  Version cannot be determined.
Call Stack (most recent call first):
  /home/user/mrustc/rustc_bootstrap/build/rustc-1.55.0-src/src/llvm-project/llvm/cmake/modules/GenerateVersionFromVCS.cmake:23 (get_source_info)
  /home/user/mrustc/rustc_bootstrap/build/rustc-1.55.0-src/src/llvm-project/llvm/cmake/modules/GenerateVersionFromVCS.cmake:45 (append_info)


[  0%] Built target LLVMHello_exports
[  0%] Built target LTO_exports
[  0%] Built target Remarks_exports
[  0%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmWriterEmitter.cpp.o
[  0%] Built target llvm_vcsrevision_h
[  0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/ItaniumDemangle.cpp.o
[  0%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/SecondLib.dir/PipSqueak.cpp.o
[  0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangle.cpp.o
[  0%] Building CXX object unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/PipSqueak.cpp.o
[  0%] Linking C executable ../../bin/count
[  0%] Built target count
[  0%] Building CXX object lib/Demangle/CMakeFiles/LLVMDemangle.dir/MicrosoftDemangleNodes.cpp.o
[  0%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/AsmWriterInst.cpp.o
[  0%] Linking CXX static library ../../../lib/libDynamicLibraryLib.a
[  0%] Built target DynamicLibraryLib
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/Attributes.cpp.o
[  1%] Linking CXX shared library SecondLib.so
/usr/lib/gcc/x86_64-linux-musl/12.2.0/../../../../x86_64-linux-musl/bin/ld: /usr/lib/gcc/x86_64-linux-musl/12.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/usr/lib/gcc/x86_64-linux-musl/12.2.0/../../../../x86_64-linux-musl/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [unittests/Support/DynamicLibrary/CMakeFiles/SecondLib.dir/build.make:97: unittests/Support/DynamicLibrary/SecondLib.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:122881: unittests/Support/DynamicLibrary/CMakeFiles/SecondLib.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CallingConvEmitter.cpp.o
[  1%] Linking CXX shared library PipSqueak.so
/usr/lib/gcc/x86_64-linux-musl/12.2.0/../../../../x86_64-linux-musl/bin/ld: /usr/lib/gcc/x86_64-linux-musl/12.2.0/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object
/usr/lib/gcc/x86_64-linux-musl/12.2.0/../../../../x86_64-linux-musl/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/build.make:97: unittests/Support/DynamicLibrary/PipSqueak.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:122855: unittests/Support/DynamicLibrary/CMakeFiles/PipSqueak.dir/all] Error 2
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeEmitterGen.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenDAGPatterns.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenHwModes.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenInstruction.cpp.o
[  1%] Linking CXX executable ../../bin/llvm-PerfectShuffle
[  1%] Built target llvm-PerfectShuffle
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenMapTable.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenRegisters.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenSchedule.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CodeGenTarget.cpp.o
[  1%] Linking CXX static library ../libLLVMDemangle.a
[  1%] Built target LLVMDemangle
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherGen.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcherOpt.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DAGISelMatcher.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DFAPacketizerEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DirectiveEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/DisassemblerEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/ExegesisEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FastISelEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/FixedLenDecoderEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/GICombinerEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/GlobalISelEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InfoByHwMode.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InstrInfoEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/InstrDocsEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/IntrinsicEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptParserEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/OptRSTEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/PredicateExpander.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/PseudoLoweringEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RISCVCompressInstEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RegisterBankEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/RegisterInfoEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SDNodeProperties.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SearchableTableEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SubtargetEmitter.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/SubtargetFeatureInfo.cpp.o
[  1%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/TableGen.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/Types.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86DisassemblerTables.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86EVEX2VEXTablesEmitter.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86FoldTablesEmitter.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86ModRMFilters.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/X86RecognizableInstr.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/WebAssemblyDisassemblerEmitter.cpp.o
[  2%] Building CXX object utils/TableGen/CMakeFiles/obj.llvm-tblgen.dir/CTagsEmitter.cpp.o
[  2%] Built target obj.llvm-tblgen
make: *** [Makefile:156: all] Error 2
thread 'main' panicked at '
command did not execute successfully, got: exit status: 2

build script failed, must exit now', /home/user/mrustc/rustc_bootstrap/build/rustc-1.55.0-src/vendor/cmake/src/lib.rs:885:5
	finished in 67.982 seconds
Build completed unsuccessfully in 0:03:49

@thepowersgang
Copy link
Owner

LLVM failing to compile it seems

/usr/lib/gcc/x86_64-linux-musl/12.2.0/../../../../x86_64-linux-musl/bin/ld: failed to set dynamic section sizes: bad value

@lrvick
Copy link
Contributor Author

lrvick commented Dec 9, 2023

Managed to get a successful build of 1.55 on x86_64-unknown-linux-musl re-using the shared llvm13 which was my ultimate goal. Should be a loop from here to get myself up to current rust!

Want to get my run_rustc changes cleaned up and put in a PR for you, so we can close out this issue.

I have some "HACK" comments in there where I have to copy system libraries into your prefix paths manually in order to get the builds to complete. Is there a more sane way to append to the library search paths in your setup so I don't have to copy all the system files like libc over?

@thepowersgang
Copy link
Owner

thepowersgang commented Dec 16, 2023

Is there a more sane way to append to the library search paths in your setup so I don't have to copy all the system files like libc over?

LD_LIBRARY_PATH maybe? It takes a colon-separated list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants