8000 fix(gcc,llvm,rust): let each compiler build hello-world from its own closure by norrietaylor · Pull Request #805 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content
8000
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions packages/gcc/build.ncl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ let version = "15.2.0" in
zstd,
],
runtime_deps = [
# gcc drives `as` and `ld` for every compile, and C programs routinely include kernel headers
binutils,
linux_headers,
gmp,
mpc,
mpfr,
Expand Down Expand Up @@ -169,7 +172,7 @@ let version = "15.2.0" in
compile_exec_code =
{
class = 'Standalone,
test_deps = [bash-bootstrap, binutils, coreutils], # TODO: Some of these need to be runtime_deps
test_deps = [bash-bootstrap, coreutils],
cmds = [
["/bin/bash", "-c", "echo 'int main() { return 0; }' > hello.c"],
["/bin/gcc", "hello.c", "-o", "hello"],
Expand All @@ -181,7 +184,7 @@ let version = "15.2.0" in
compile_exec_output =
{
class = 'Standalone,
test_deps = [bash-bootstrap, binutils, coreutils, grep], # TODO: Some of these need to be runtime_deps
test_deps = [bash-bootstrap, coreutils, grep],
cmds = [
["/bin/bash", "-c", "cat > print.c << 'EOF'\n#include <stdio.h>\nint main() {\n printf(\"Hello World\");\n return 0;\n}\nEOF"],
["/bin/gcc", "print.c", "-o", "print"],
Expand All @@ -193,7 +196,7 @@ let version = "15.2.0" in
compile_exec_math =
{
class = 'Standalone,
test_deps = [bash-bootstrap, binutils, coreutils, grep], # TODO: Some of these need to be runtime_deps
test_deps = [bash-bootstrap, coreutils, grep],
cmds = [
["/bin/bash", "-c", "cat > math.c << 'EOF'\n#include <stdio.h>\nint main() {\n int result = 2 + 2;\n printf(\"%d\", result);\n return 0;\n}\nEOF"],
["/bin/gcc", "math.c", "-o", "math"],
Expand All @@ -204,7 +207,7 @@ let version = "15.2.0" in
compile_exec_linking =
{
class = 'Standalone,
test_deps = [bash-bootstrap, binutils, coreutils, grep], # TODO: Some of these need to be runtime_deps
test_deps = [bash-bootstrap, coreutils, grep],
cmds = [
["/bin/bash", "-c", "cat > func.c << 'EOF'\nint multiply(int a, int b) {\n return a * b;\n}\nEOF"],
["/bin/bash", "-c", "cat > main.c << 'EOF'\n#include <stdio.h>\nint multiply(int a, int b);\nint main() {\n printf(\"%d\", multiply(6, 7));\n return 0;\n}\nEOF"],
Expand All @@ -214,5 +217,20 @@ let version = "15.2.0" in
["/bin/bash", "-c", "./multi | grep -q '^42$'"],
],
} | Test,

# Only the compiler's own runtime closure may supply as, ld and the kernel headers here.
compile_exec_cc_cxx_kernel_headers =
{
class = 'Standalone,
test_deps = [bash-bootstrap, coreutils],
cmds = [
["/bin/bash", "-c", "echo 'int main() { return 0; }' > hello.c"],
["/bin/cc", "hello.c", "-o", "hello"],
["/bin/bash", "-c", "./hello"],
["/bin/bash", "-c", "printf '#include <linux/types.h>\\n#include <iostream>\\nint main() { __u32 x = 42; std::cout << x; return 0; }\\n' > hello.cc"],
["/bin/g++", "hello.cc", "-o", "hellocc"],
["/bin/bash", "-c", "test \"$(./hellocc)\" = 42"],
],
} | Test,
},
} | BuildSpec
4 changes: 2 additions & 2 deletions packages/gcc/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ make -j$(nproc)
# TODO make -k check
make DESTDIR=$OUTPUT_DIR install-strip

# TODO
# ln -sf $OUTPUT_DIR/usr/bin/gcc $OUTPUT_DIR/usr/bin/cc
# gcc installs `c++` but not `cc`, the name build tools and rustc's default linker invoke
ln -s gcc $OUTPUT_DIR/usr/bin/cc
21 changes: 20 additions & 1 deletion packages/llvm/build.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
let { subsetOf, Attrs, BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, .. } = import "minimal.ncl" in
let { subsetOf, Attrs, BuildSpec, Local, OutputBin, OutputData, OutputLib, Source, Test, .. } = import "minimal.ncl" in
let base = import "../base/build.ncl" in
let bash-bootstrap = import "../bash-bootstrap/build.ncl" in
let binutils = import "../binutils/build.ncl" in
let cmake = import "../cmake/build.ncl" in
let libffi = import "../libffi/build.ncl" in
let llvm-bootstrap = import "../llvm-bootstrap/build.ncl" in
Expand All @@ -8,6 +10,7 @@ let python = import "../python/build.ncl" in
let toolchain = import "../toolchain/build.ncl" in
let coreutils = import "../coreutils/build.ncl" in
let glibc = import "../glibc/build.ncl" in
let linux_headers = import "../linux_headers/build.ncl" in
let gcc = import "../gcc/build.ncl" in
let zlib = import "../zlib/build.ncl" in
let version = "21.1.8" in
Expand Down Expand Up @@ -56,8 +59,10 @@ let version = "21.1.8" in
toolchain,
],
runtime_deps = [
binutils, # clang's driver links through `ld`
coreutils, # For /usr/bin/env
glibc,
linux_headers,
libffi,
zlib,
subsetOf gcc ["libgcc", "libstdcpp"],
Expand Down Expand Up @@ -102,4 +107,18 @@ let version = "21.1.8" in
},
build_cost_multiple = 6,
} | Attrs,

tests = {
# Only clang's own runtime closure may supply ld and the kernel headers here.
compile_exec_c_kernel_headers =
{
class = 'Standalone,
test_deps = [bash-bootstrap, coreutils],
cmds = [
["/bin/bash", "-c", "printf '#include <linux/types.h>\\nint main() { __u32 x = 0; return x; }\\n' > hello.c"],
["/bin/clang", "hello.c", "-o", "hello"],
["/bin/bash", "-c", "./hello"],
],
} | Test,
},
} | BuildSpec
22 changes: 20 additions & 2 deletions packages/rust/build.ncl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
let { subsetOf, Attrs, BuildSpec, Local, Needs, OutputBin, OutputData, OutputLib, Source, .. } = import "minimal.ncl" in
let { subsetOf, Attrs, BuildSpec, Local, Needs, OutputBin, OutputData, OutputLib, Source, Test, .. } = import "minimal.ncl" in
let { target, .. } = import "config.ncl" in
let base = import "../base/build.ncl" in
let bash-bootstrap = import "../bash-bootstrap/build.ncl" in
let coreutils = import "../coreutils/build.ncl" in
let cmake = import "../cmake/build.ncl" in
let curl = import "../curl/build.ncl" in
let llvm = import "../llvm/build.ncl" in
Expand Down Expand Up @@ -33,7 +35,6 @@ let version = "1.98.1" in
libssh2,
pkgconf,
python,
toolchain,
]
# stage0 = the rustc-1.97.1 rung (1.98.1's src/stage0 pins 1.97.1), built by the chain
# gcc-15.2.0 -> mrustc 0.12.0 -> rustc-1.90.0 -> 1.91.1 -> ... -> 1.97.1. amd64 takes the
Expand Down Expand Up @@ -73,6 +74,9 @@ let version = "1.98.1" in
openssl,
sqlite,
subsetOf gcc ["libgcc", "libstdcpp"],
# rustc links through `cc` by default; toolchain brings gcc (which provides `cc`), binutils,
# glibc and the kernel headers, the same set the rust stack adds
toolchain,
],

cmd = "./build.sh",
Expand Down Expand Up @@ -103,4 +107,18 @@ let version = "1.98.1" in
},
build_cost_multiple = 3,
} | Attrs,

tests = {
# Only rust's own runtime closure may supply the `cc` that rustc links through here.
compile_exec_hello =
{
class = 'Standalone,
test_deps = [bash-bootstrap, coreutils],
cmds = [
["/bin/bash", "-c", "echo 'fn main() { println!(\"hello\"); }' > hello.rs"],
["/bin/rustc", "hello.rs", "-o", "hello"],
["/bin/bash", "-c", "test \"$(./hello)\" = hello"],
],
} | Test,
},
} | BuildSpec
Loading
0