diff --git a/Makefile b/Makefile index 01f1654..ca23a22 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,14 @@ mode ?= debug out_dir ?= build/$(arch) out_img ?= build/$(arch).img out_qcow2 ?= build/$(arch).qcow2 +python ?= 0 +golang ?= 0 +iperf3 ?= 0 +redis ?= 0 +nginx ?= 0 +ucore ?= 0 +test ?= 0 +biscuit ?= 0 rcore_fs_fuse_revision ?= 351d382 @@ -28,7 +36,7 @@ cmake_build_args += -DCMAKE_BUILD_TYPE=Release endif -.PHONY: all clean build rust ucore biscuit bin busybox nginx redis alpine iperf3 python +.PHONY: all clean build rust ucore biscuit bin busybox nginx redis alpine iperf3 python golang all: build @@ -39,13 +47,16 @@ rust: @cp $(rust_bins) $(out_dir)/rust ucore: +ifeq ($(ucore), 1) @echo Building ucore programs @mkdir -p ucore/build @cd ucore/build && cmake $(cmake_build_args) .. && make @rm -rf $(out_dir)/ucore && mkdir -p $(out_dir)/ucore @cp $(ucore_bin_path)/* $(out_dir)/ucore +endif biscuit: +ifeq ($(biscuit), 1) ifneq ($(shell uname)-$(arch), Darwin-$(filter $(arch), riscv32 riscv64 aarch64)) @echo Building biscuit programs @mkdir -p biscuit/build @@ -53,6 +64,7 @@ ifneq ($(shell uname)-$(arch), Darwin-$(filter $(arch), riscv32 riscv64 aarch64) @rm -rf $(out_dir)/biscuit && mkdir -p $(out_dir)/biscuit @cp $(biscuit_bin_path)/* $(out_dir)/biscuit endif +endif $(busybox): ifeq ($(arch), x86_64) @@ -73,6 +85,7 @@ endif busybox: $(busybox) nginx: +ifeq ($(nginx), 1) ifneq ($(shell uname), Darwin) @echo Building nginx mkdir -p $(out_dir)/usr/local/nginx/conf @@ -81,16 +94,36 @@ ifneq ($(shell uname), Darwin) @cp nginx/build/$(arch)/nginx $(out_dir) @cp nginx/nginx.conf $(out_dir)/usr/local/nginx/conf endif +endif python: +ifeq ($(python), 1) +ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) ifneq ($(shell uname), Darwin) @echo Building Python - @mkdir -p $(out_dir) + @mkdir -p $(out_dir)/python @cd python && make arch=$(arch) all - @cp -r python/build/$(arch)/target $(out_dir)/python + @cp -r python/build/$(arch)/target/* $(out_dir)/python + @dd if=/dev/urandom of=$(out_dir)/dev/urandom count=512 +endif +endif +endif + +golang: +ifeq ($(golang), 1) +ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) +ifneq ($(shell uname), Darwin) + @echo Building Golang + @mkdir -p $(out_dir)/golang + @cd golang && make arch=$(arch) all + @cp -r golang/build/$(arch)/target/* $(out_dir)/golang + @dd if=/dev/urandom of=$(out_dir)/dev/urandom count=512 +endif +endif endif redis: +ifeq ($(redis), 1) ifneq ($(shell uname), Darwin) @echo Building redis @mkdir -p $(out_dir) @@ -99,8 +132,10 @@ ifneq ($(shell uname), Darwin) @cp redis/build/$(arch)/redis-cli $(out_dir)/redis-cli @cp redis/redis.conf $(out_dir)/redis.conf endif +endif iperf3: +ifeq ($(iperf3), 1) ifeq ($(arch), x86_64) ifneq ($(shell uname), Darwin) @echo Building iperf3 @@ -110,6 +145,7 @@ ifneq ($(shell uname), Darwin) @cp iperf3/build/$(arch)/iperf3 $(out_dir) endif endif +endif $(alpine): -wget "http://dl-cdn.alpinelinux.org/alpine/v3.9/releases/$(arch)/$(alpine_file)" -O $(alpine) @@ -122,13 +158,15 @@ ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) endif test: +ifeq ($(test), 1) ifeq ($(arch), $(filter $(arch), x86_64 aarch64)) @echo setup test DIR @mkdir -p $(out_dir) @cp -r testsuits_alpine $(out_dir)/test endif +endif -build: rust ucore biscuit $(busybox) nginx redis iperf3 python test +build: rust ucore biscuit $(busybox) nginx redis iperf3 python golang test sfsimg: $(out_qcow2) diff --git a/golang/.gitignore b/golang/.gitignore new file mode 100644 index 0000000..e390b12 --- /dev/null +++ b/golang/.gitignore @@ -0,0 +1 @@ +build/** \ No newline at end of file diff --git a/golang/Makefile b/golang/Makefile new file mode 100644 index 0000000..f0d13e7 --- /dev/null +++ b/golang/Makefile @@ -0,0 +1,74 @@ +golang_version := 1.12.7 + +golang_tarball := go$(golang_version).src.tar.gz +golang_tarball_path := src/$(golang_tarball) + +golang_bin_tarball := go$(golang_version).linux-amd64.tar.gz +golang_bin_tarball_path := src/$(golang_bin_tarball) + +build_dir := build/$(arch) +golang_bin_dir := $(build_dir)/go +golang_src_dir := $(build_dir)/go/src +golang_src_build_dir := $(build_dir)/target/src + +prefix := $(arch)-linux-musl- + +bin := $(build_dir)/target/bin/go + +ifeq ($(arch), mipsel) + prefix := mipsel-linux-musln32- + go_arch := mipsle +else ifeq ($(arch), aarch64) + go_arch := arm64 +else ifeq ($(arch), x86_64) + go_arch := amd64 +endif + +cc := $(prefix)gcc +cxx := $(prefix)g++ +strip := $(prefix)strip + +$(golang_bin_tarball_path): + wget https://dl.google.com/go/$(golang_bin_tarball) -O $(golang_bin_tarball_path) + +$(golang_bin_dir): $(golang_bin_tarball_path) + mkdir -p $(build_dir) + cd $(build_dir) && tar xvf ../../$(golang_bin_tarball_path) + cd $(build_dir)/go && patch -p1 < ../../../set-external-linker.patch + touch $(golang_bin_dir) + +$(golang_src_build_dir): $(golang_src_dir) + mkdir -p $(build_dir)/target + cp -r $(golang_src_dir) $(golang_src_build_dir) + +$(bin): $(golang_bin_dir) $(golang_src_build_dir) + cd $(golang_src_build_dir) && \ + GOROOT_BOOTSTRAP=`realpath ../../go` \ + GOROOT_FINAL=/golang \ + GOOS=linux \ + GOARCH=$(go_arch) \ + CC_FOR_TARGET=$(cc) \ + CXX_FOR_TARGET=$(cxx) \ + CC=x86_64-linux-musl-gcc \ + CXX=x86_64-linux-musl-g++ \ + LD=x86_64-linux-musl-ld \ + GO_LDFLAGS="-buildmode=pie" \ + CGO_ENABLED=1 \ + ./make.bash + + # if [ "$(arch)" != "x86_64" ]; then \ + # mv $(build_dir)/target/bin/*_*/* $(build_dir)/target/bin; \ + # rm -rf $(build_dir)/target/bin/*_*; \ + # rm -rf $(build_dir)/target/pkg/linux_amd64; \ + # rm -rf $(build_dir)/target/pkg/tool/linux_amd64; \ + # fi + + # rm -rf $(build_dir)/target/pkg/obj + # rm -rf $(build_dir)/target/pkg/bootstrap + +.PHONY: all clean + +all: $(bin) + +clean: + rm -rf build/$(arch) diff --git a/golang/set-external-linker.patch b/golang/set-external-linker.patch new file mode 100644 index 0000000..68a645f --- /dev/null +++ b/golang/set-external-linker.patch @@ -0,0 +1,106 @@ +This patch is intended to fix https://github.com/golang/go/issues/18243 + +diff --git a/src/cmd/link/internal/amd64/obj.go b/src/cmd/link/internal/amd64/obj.go +index 87e8091..4470e05 100644 +--- a/src/cmd/link/internal/amd64/obj.go ++++ b/src/cmd/link/internal/amd64/obj.go +@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { + PEreloc1: pereloc1, + TLSIEtoLE: tlsIEtoLE, + +- Linuxdynld: "/lib64/ld-linux-x86-64.so.2", ++ Linuxdynld: "/lib/ld-musl-x86_64.so.1", + Freebsddynld: "/libexec/ld-elf.so.1", + Openbsddynld: "/usr/libexec/ld.so", + Netbsddynld: "/libexec/ld.elf_so", +diff --git a/src/cmd/link/internal/arm/obj.go b/src/cmd/link/internal/arm/obj.go +index da16f92..fd14940 100644 +--- a/src/cmd/link/internal/arm/obj.go ++++ b/src/cmd/link/internal/arm/obj.go +@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + Machoreloc1: machoreloc1, + +- Linuxdynld: "/lib/ld-linux.so.3", // 2 for OABI, 3 for EABI ++ Linuxdynld: "/lib/ld-musl-armhf.so.1", + Freebsddynld: "/usr/libexec/ld-elf.so.1", + Openbsddynld: "/usr/libexec/ld.so", + Netbsddynld: "/libexec/ld.elf_so", +diff --git a/src/cmd/link/internal/arm64/obj.go b/src/cmd/link/internal/arm64/obj.go +index 6b386ad..9986371 100644 +--- a/src/cmd/link/internal/arm64/obj.go ++++ b/src/cmd/link/internal/arm64/obj.go +@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + Machoreloc1: machoreloc1, + +- Linuxdynld: "/lib/ld-linux-aarch64.so.1", ++ Linuxdynld: "/lib/ld-musl-aarch64.so.1", + + Freebsddynld: "XXX", + Openbsddynld: "XXX", +diff --git a/src/cmd/link/internal/mips/obj.go b/src/cmd/link/internal/mips/obj.go +index c5d3451..fd85e63 100644 +--- a/src/cmd/link/internal/mips/obj.go ++++ b/src/cmd/link/internal/mips/obj.go +@@ -60,7 +60,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + Machoreloc1: machoreloc1, + +- Linuxdynld: "/lib/ld.so.1", ++ Linuxdynld: "/lib/ld-musl-mipsle.so.1", + + Freebsddynld: "XXX", + Openbsddynld: "XXX", +diff --git a/src/cmd/link/internal/mips64/obj.go b/src/cmd/link/internal/mips64/obj.go +index 83974e5..0f65647 100644 +--- a/src/cmd/link/internal/mips64/obj.go ++++ b/src/cmd/link/internal/mips64/obj.go +@@ -59,7 +59,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + Machoreloc1: machoreloc1, + +- Linuxdynld: "/lib64/ld64.so.1", ++ Linuxdynld: "/lib/ld-musl-mips64le.so.1", + Freebsddynld: "XXX", + Openbsddynld: "XXX", + Netbsddynld: "XXX", +diff --git a/src/cmd/link/internal/ppc64/obj.go b/src/cmd/link/internal/ppc64/obj.go +index 273d9b4..abe257d 100644 +--- a/src/cmd/link/internal/ppc64/obj.go ++++ b/src/cmd/link/internal/ppc64/obj.go +@@ -62,7 +62,7 @@ func Init() (*sys.Arch, ld.Arch) { + Machoreloc1: machoreloc1, + + // TODO(austin): ABI v1 uses /usr/lib/ld.so.1, +- Linuxdynld: "/lib64/ld64.so.1", ++ Linuxdynld: "/lib/ld-musl-powerpc64le.so.1", + + Freebsddynld: "XXX", + Openbsddynld: "XXX", +diff --git a/src/cmd/link/internal/s390x/obj.go b/src/cmd/link/internal/s390x/obj.go +index 9ac7eb8..b3f7a66 100644 +--- a/src/cmd/link/internal/s390x/obj.go ++++ b/src/cmd/link/internal/s390x/obj.go +@@ -57,7 +57,7 @@ func Init() (*sys.Arch, ld.Arch) { + Gentext: gentext, + Machoreloc1: machoreloc1, + +- Linuxdynld: "/lib64/ld64.so.1", ++ Linuxdynld: "/lib/ld-musl-s390x.so.1", + + // not relevant for s390x + Freebsddynld: "XXX", +diff --git a/src/cmd/link/internal/x86/obj.go b/src/cmd/link/internal/x86/obj.go +index 6a744dc..d81f392 100644 +--- a/src/cmd/link/internal/x86/obj.go ++++ b/src/cmd/link/internal/x86/obj.go +@@ -58,7 +58,7 @@ func Init() (*sys.Arch, ld.Arch) { + Machoreloc1: machoreloc1, + PEreloc1: pereloc1, + +- Linuxdynld: "/lib/ld-linux.so.2", ++ Linuxdynld: "/lib/ld-musl-i386.so.1", + Freebsddynld: "/usr/libexec/ld-elf.so.1", + Openbsddynld: "/usr/libexec/ld.so", + Netbsddynld: "/usr/libexec/ld.elf_so", \ No newline at end of file diff --git a/golang/src/.gitignore b/golang/src/.gitignore new file mode 100644 index 0000000..c32b546 --- /dev/null +++ b/golang/src/.gitignore @@ -0,0 +1 @@ +*.tar.gz \ No newline at end of file diff --git a/python/Makefile b/python/Makefile index 5ece4d7..c0b6fc2 100644 --- a/python/Makefile +++ b/python/Makefile @@ -40,13 +40,6 @@ $(bin): $(python_dir) mkdir -p $(prefix_dir) cd $(python_dir) && make -j8 altinstall -# $(bin_unstripped): $(prefix_dir)/bin/python3.7 -# cp $(bin) $(bin_unstripped) - -# $(bin): $(bin_unstripped) -# cp $(bin_unstripped) $(bin) -# $(strip) $(bin) - .PHONY: all clean all: $(bin)