mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-23 05:14:18 +08:00
Recipe for rust
This commit is contained in:
parent
ffc9952f29
commit
13edf0f4a9
11
recipes/rust/config.toml
Normal file
11
recipes/rust/config.toml
Normal file
@ -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"]
|
||||
24
recipes/rust/llvm-config
Executable file
24
recipes/rust/llvm-config
Executable file
@ -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)
|
||||
65
recipes/rust/recipe.sh
Normal file
65
recipes/rust/recipe.sh
Normal file
@ -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
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user