From 13edf0f4a9385ee59c266237bd2cb8caf9c219fe Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 13 Jun 2017 18:57:04 -0700 Subject: [PATCH 1/2] Recipe for rust --- recipes/rust/config.toml | 11 +++++++ recipes/rust/llvm-config | 24 +++++++++++++++ recipes/rust/recipe.sh | 65 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+) create mode 100644 recipes/rust/config.toml create mode 100755 recipes/rust/llvm-config create mode 100644 recipes/rust/recipe.sh diff --git a/recipes/rust/config.toml b/recipes/rust/config.toml new file mode 100644 index 000000000..ba7391371 --- /dev/null +++ b/recipes/rust/config.toml @@ -0,0 +1,11 @@ +[rust] +backtrace = false + +[target.x86_64-unknown-redox] +cc = "x86_64-elf-redox-gcc" +cxx = "x86_64-elf-redox-g++" +llvm-config = "./llvm-config" + +[build] +host = ["x86_64-unknown-redox"] +target = ["x86_64-unknown-redox"] diff --git a/recipes/rust/llvm-config b/recipes/rust/llvm-config new file mode 100755 index 000000000..f2027dec9 --- /dev/null +++ b/recipes/rust/llvm-config @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +import sys +import os + +args = sys.argv[1:] +prefix = os.path.realpath(os.path.dirname(os.path.abspath(sys.argv[0])) + "/../llvm-root") + +# The values here are copied from the output of llvm-config running under Redox. +# This is a hack, and should be replaced if possible. + +if args == ["--version"]: + print("4.0.1") +elif args == ["--cxxflags"]: + print("-I" + prefix + "/include --std=gnu++11 -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=gnu++11 -g -fno-exceptions -fno-rtti -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS") +elif args == ["--components"]: + print("all all-targets analysis asmparser asmprinter bitreader bitwriter codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb demangle engine executionengine globalisel instcombine instrumentation interpreter ipo irreader libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mirparser native nativecodegen objcarcopts object objectyaml option orcjit passes profiledata runtimedyld scalaropts selectiondag support symbolize tablegen target transformutils vectorize x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils") +elif args == ['--libs', '--link-static', 'asmparser', 'bitreader', 'bitwriter', 'instrumentation', 'interpreter', 'ipo', 'linker', 'mcjit', 'x86']: + print("-lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMTarget -lLLVMScalarOpts -lLLVMInstCombine -lLLVMInstrumentation -lLLVMTransformUtils -lLLVMBitWriter -lLLVMAnalysis -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMProfileData -lLLVMBitReader -lLLVMAsmParser -lLLVMCore -lLLVMSupport -lLLVMDemangle -lstdc++ -lgcc") + # FIXME last two -l are are a hack +elif args == ["--link-static", "--ldflags"]: + print("-L" + prefix + "/lib"); +else: + sys.exit(1) diff --git a/recipes/rust/recipe.sh b/recipes/rust/recipe.sh new file mode 100644 index 000000000..39a24fa05 --- /dev/null +++ b/recipes/rust/recipe.sh @@ -0,0 +1,65 @@ +mIT=https://github.com/ids1024/rust.git +BRANCH=compile-redox + +ARCH=x86_64 +HOST=x86_64-elf-redox +RUST_HOST=x86_64-unknown-redox +LLVM_PREFIX=$PWD/llvm-root +SYSROOT=/usr/x86_64-elf-redox +unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP + +LLVM_CMAKE_ARGS=(-Wno-dev -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX="$LLVM_PREFIX" -DLLVM_DEFAULT_TARGET_TRIPLE=$HOST -DLLVM_TARGET_ARCH=$ARCH -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_SYSTEM_NAME=Generic -DPYTHON_EXECUTABLE=/usr/bin/python2 -DUNIX=1 -DLLVM_ENABLE_THREADS=Off -DLLVM_INCLUDE_TESTS=OFF -target=$HOST -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen -I"$SYSROOT/include" -DCMAKE_CXX_FLAGS='--std=gnu++11' -DLLVM_TOOL_LTO_BUILD=Off -DLLVM_TOOL_LLVM_PROFDATA_BUILD=Off -DLLVM_TOOL_LLI_BUILD=Off -DLLVM_TOOL_RDOBJ_BUILD=Off -DLLVM_TOOL_LLVM_COV_BUILD=Off -DLLVM_TOOL_LLVM_XRAY_BUILD=Off -DLLVM_TOOL_LLVM_LTO2_BUILD=Off -DLLVM_TOOL_LLVM_LTO_BUILD=Off -DLLVM_TOOL_LLVM_RTDYLD_BUILD=Off) + +function recipe_version { + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" + skip=1 +} + +function recipe_update { + echo "skipping update" + skip=1 +} + +function recipe_build { + # Download patched LLVM + if [ -d llvm-redox ] + then + git -C llvm-redox pull + else + git clone https://github.com/ids1024/llvm.git -b redox2 --depth 1 llvm-redox + fi + + # Build LLVM + rm -rf $LLVM_PREFIX + mkdir $LLVM_PREFIX + mkdir -p llvm-redox/build + pushd llvm-redox/build + CC=$HOST-gcc CXX=$HOST-g++ cmake "${LLVM_CMAKE_ARGS[@]}" .. + make -j"$(nproc)" + make install + popd + + cp ../{config.toml,llvm-config} ./ + python x.py build + skip=1 +} + +function recipe_test { + echo "skipping test" + skip=1 +} + +function recipe_clean { + make clean + skip=1 +} + +function recipe_stage { + binpath="$1/bin" + libpath="$1/lib/rustlib/${RUST_HOST}/lib" + mkdir -p "$binpath" "$libpath" + cp -fv "build/${RUST_HOST}/stage2/bin/rustc" "$binpath" + ${HOST}-strip "$binpath/rustc" + cp -fv $(find build/${RUST_HOST}/stage2/lib/rustlib/${RUST_HOST}/lib/ -type f | grep -v librustc) "$libpath" + skip=1 +} From b4e0ff01a8da2e9d46e773c2deb556809eda0af0 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 13 Jun 2017 20:07:30 -0700 Subject: [PATCH 2/2] More llvm-root into build/ --- recipes/rust/llvm-config | 2 +- recipes/rust/recipe.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/rust/llvm-config b/recipes/rust/llvm-config index f2027dec9..0ac59cda3 100755 --- a/recipes/rust/llvm-config +++ b/recipes/rust/llvm-config @@ -4,7 +4,7 @@ import sys import os args = sys.argv[1:] -prefix = os.path.realpath(os.path.dirname(os.path.abspath(sys.argv[0])) + "/../llvm-root") +prefix = os.path.realpath(os.path.dirname(os.path.abspath(sys.argv[0])) + "/llvm-root") # The values here are copied from the output of llvm-config running under Redox. # This is a hack, and should be replaced if possible. diff --git a/recipes/rust/recipe.sh b/recipes/rust/recipe.sh index 39a24fa05..62b0b5b86 100644 --- a/recipes/rust/recipe.sh +++ b/recipes/rust/recipe.sh @@ -4,7 +4,7 @@ BRANCH=compile-redox ARCH=x86_64 HOST=x86_64-elf-redox RUST_HOST=x86_64-unknown-redox -LLVM_PREFIX=$PWD/llvm-root +LLVM_PREFIX=$PWD/build/llvm-root SYSROOT=/usr/x86_64-elf-redox unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP