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

Fix building on OpenBSD #353

Merged
merged 6 commits into from
Jan 30, 2025
Merged

Conversation

realchonk
Copy link
Contributor

@realchonk realchonk commented Jan 27, 2025

I was able to build and use mrustc on OpenBSD, but with a few changes.
To be able to use mrustc, I had to set CC=egcc (gcc-11.2.0),
because compiler_builtins would emit wrong assembly for clang.

Please test my changes, so they don't affect other systems.

compiler_builtins failure with clang:
--- BUILDING compiler_builtins v0.1.101 (15.8% 1r,0w,15b,3c/19t)
> tools/bin/mrustc rustc-1.74.0-src/vendor/compiler_builtins/src/lib.rs -o output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib -C emit-depfile=output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.d --cfg debug_assertions -O -L output-1.74.0 --cfg feature="compiler-builtins" --cfg feature="rustc-dep-of-std" --cfg feature="core" --cfg feature="dep:core" --crate-name compiler_builtins --crate-type rlib --crate-tag 0_1_101_H10c --cfg feature="unstable" --edition 2018 --extern core=output-1.74.0/librustc_std_workspace_core-1_99_0.rlib > output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib_dbg.txt
 (15.8% 1r,0w,15b,3c/19t): compiler_builtins v0.1.101
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:14252:83: error: invalid input constraint '0' in asm
        __asm__ __volatile__("div %2;\n " : "+r" (asm_rax), "+r" (asm_rdx) : "r" (arg1), "0" (asm_rax), "1" (asm_rdx):);
                                                                                         ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:14349:84: error: invalid input constraint '0' in asm
        __asm__ __volatile__("div %2;\n " : "+r" (asm_rax), "+r" (asm_rdx) : "r" (var38), "0" (asm_rax), "1" (asm_rdx):);
                                                                                          ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:14399:83: error: invalid input constraint '0' in asm
        __asm__ __volatile__("div %2;\n " : "+r" (asm_rax), "+r" (asm_rdx) : "r" (var3), "0" (asm_rax), "1" (asm_rdx):);
                                                                                         ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:14424:83: error: invalid input constraint '0' in asm
        __asm__ __volatile__("div %2;\n " : "+r" (asm_rax), "+r" (asm_rdx) : "r" (var3), "0" (asm_rax), "1" (asm_rdx):);
                                                                                         ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:16076:89: error: invalid input constraint '0' in asm
        __asm__ __volatile__("rep movsb;\n " : "+r" (asm_rdi), "+r" (asm_rsi) : "r" (asm_ecx), "0" (asm_rdi), "1" (asm_rsi):);
                                                                                               ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:16087:89: error: invalid input constraint '0' in asm
        __asm__ __volatile__("rep movsq;\n " : "+r" (asm_rdi), "+r" (asm_rsi) : "r" (asm_rcx), "0" (asm_rdi), "1" (asm_rsi):);
                                                                                               ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:16145:73: error: invalid input constraint '0' in asm
        __asm__ __volatile__("rep stosb;\n " : "+r" (asm_rdi) : "r" (asm_ecx), "0" (asm_rdi), "r" (asm_rax):);
                                                                               ^
output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.c:16154:73: error: invalid input constraint '0' in asm
        __asm__ __volatile__("rep stosq;\n " : "+r" (asm_rdi) : "r" (asm_rcx), "0" (asm_rdi), "r" (asm_rax):);
                                                                               ^
8 errors generated.
C Compiler failed to execute - error code 256
Process exited with non-zero exit status 1
FAILING COMMAND: tools/bin/mrustc rustc-1.74.0-src/vendor/compiler_builtins/src/lib.rs -o output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib -C emit-depfile=output-1.74.0/libcompiler_builtins-0_1_101_H10c.rlib.d --cfg debug_assertions
-O -L output-1.74.0 --cfg feature="compiler-builtins" --cfg feature="rustc-dep-of-std" --cfg feature="core" --cfg feature="dep:core" --crate-name compiler_builtins --crate-type rlib --crate-tag 0_1_101_H10c --cfg feature="unstable" --edition 2018 --extern core=output-1.74.0/librustc_std_workspace_core-1_99_0.rlib

@realchonk realchonk changed the title Openbsd Fix building on OpenBSD Jan 27, 2025
Makefile Outdated Show resolved Hide resolved
@thepowersgang thepowersgang merged commit 972b6ae into thepowersgang:master Jan 30, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants