Mercurial > hg > Singularity > CbC
changeset 0:e90bb8bec611 default tip
init
author | Ken Miyahira <e175733@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 25 Dec 2020 19:02:23 +0900 |
parents | |
children | |
files | .hgignore README.md cbc_gcc.def cbc_gcc_cross.def cbc_llvm.def |
diffstat | 5 files changed, 194 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Fri Dec 25 19:02:23 2020 +0900 @@ -0,0 +1,1 @@ +.DS_Store \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Fri Dec 25 19:02:23 2020 +0900 @@ -0,0 +1,68 @@ +# Singularity/CbC + +Cross Compile で吐き出されたバイナリは 32bit OS でのみ動作確認 + +## CbC on GCC + +cbc を gcc で compile できるようにするやつ + +### Build & Usage + +#### Build +```sh +$ singularity build --fakeroot cbc_gcc.sif cbc_gcc.def +``` + +#### Usage +```sh +$ singularity shell cbc_gcc.sif +$ gcc hello.cbc +$ ./a.out +hello, world!! +``` + +## CbC on GCC Cross Compiler + +cbc を ARM バイナリで吐き出す + +### Build & Usage + +#### Build +```sh +$ singularity build --fakeroot cbc_gcc_cross.sif cbc_gcc_cross.def +``` + +#### Usage +```sh +$ singularity shell cbc_gcc_cross.sif +$ arm-linux-gnueabihf-gcc hello.cbc +$ file ./a.out +a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, not stripped +``` + +## CbC on LLVM + +cbc を llvm/clang で compile できるようにするやつ、cross もできるよ + +### Build & Usage + +#### Build +```sh +$ singularity build --fakeroot cbc_llvm.sif cbc_llvm.def +``` + +#### Usage +```sh +$ singularity shell cbc_llvm.sif +$ clang hello.cbc +$ ./a.out +hello, world!! +``` + +#### Usage (Cross Compile) +```sh +$ singularity shell cbc_llvm.sif +$ clang hello.cbc --target=arm-linux-gnueabihf +$ file a.out +a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, not stripped +``` \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbc_gcc.def Fri Dec 25 19:02:23 2020 +0900 @@ -0,0 +1,29 @@ +BootStrap: docker +From: ubuntu:20.04 + +%post + apt-get update + apt-get upgrade -y + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + mercurial \ + libmpc-dev \ + libgmp-dev \ + libmpfr-dev \ + build-essential \ + flex \ + gdb \ + lldb \ + zsh + hg clone http://www.cr.ie.u-ryukyu.ac.jp/hg/CbC/CbC_gcc/ + mkdir -p /usr/local/cbc_gcc + cd /usr/local/cbc_gcc + sh /CbC_gcc/configure CFLAGS="-g3 -O0" --prefix=/usr/local/cbc_gcc \ + --disable-nls --disable-bootstrap --enable-languages=c \ + --enable-checking=tree,rtl,assert,types --disable-multilib + make -j16 + make install + +%environment + export PATH=/usr/local/cbc_gcc/bin:$PATH + export CBC_COMPILER=/usr/local/cbc_gcc/bin/gcc \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbc_gcc_cross.def Fri Dec 25 19:02:23 2020 +0900 @@ -0,0 +1,52 @@ +BootStrap: docker +From: ubuntu:20.04 + +%post + apt-get update + apt-get upgrade -y + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + mercurial \ + build-essential \ + wget \ + libmpc-dev \ + libgmp-dev \ + libmpfr-dev \ + flex \ + libssl-dev \ + ninja-build \ + g++-multilib \ + gcc-multilib \ + cmake \ + ninja-build + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + crossbuild-essential-armhf + + # install cbc_gcc + hg clone http://www.cr.ie.u-ryukyu.ac.jp/hg/CbC/CbC_gcc/ + mkdir -p /usr/local/cbc_gcc + mkdir -p /CbC_gcc/builddir + cd /CbC_gcc/builddir + sh /CbC_gcc/configure -v --prefix=/usr/local/cbc_gcc --target=arm-linux-gnueabihf \ + --enable-languages=c,lto --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard \ + --disable-multilib --disable-nls --enable-checking=tree,rtl,assert,types "CFLAGS=-g3 -O0" \ + --disable-libstdcxx --disable-libssp --disable-libstdcxx-pch --disable-libmudflap \ + --with-newlib --with-sysroot=/ --with-as=/usr/arm-linux-gnueabihf/bin/as --with-ld=/usr/arm-linux-gnueabihf/bin/ld + ./config.status + make -j$(nproc) all-gcc + make install-gcc + + # setup linker + ln -s /usr/arm-linux-gnueabihf/lib/crt*.o /usr/local/cbc_gcc/lib/gcc/arm-linux-gnueabihf/10.0.1/ && \ + ln -s /usr/lib/gcc-cross/arm-linux-gnueabihf/9/crt*.o /usr/local/cbc_gcc/lib/gcc/arm-linux-gnueabihf/10.0.1/ && \ + ln -s /usr/lib/gcc-cross/arm-linux-gnueabihf/9/libgcc* /usr/local/cbc_gcc/lib/gcc/arm-linux-gnueabihf/10.0.1/ + + # download arm-none-eabi + wget "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2?revision=ca0cbf9c-9de2-491c-ac48-898b5bbc0443&la=en&hash=68760A8AE66026BCF99F05AC017A6A50C6FD832A" -O /tmp/arm.tar.bz2 && \ + tar -jxvf /tmp/arm.tar.bz2 -C /opt && \ + mv /opt/gcc-arm-none-eabi-10-2020-q4-major /opt/tools + +%environment + export LANG=C + export PATH=/usr/local/cbc_gcc/bin:$PATH
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbc_llvm.def Fri Dec 25 19:02:23 2020 +0900 @@ -0,0 +1,44 @@ +BootStrap: docker +From: ubuntu:20.04 + +%post + apt-get update + apt-get upgrade -y + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + mercurial \ + wget \ + libssl-dev \ + vim \ + build-essential \ + ninja-build \ + clang \ + cmake \ + gcc-multilib \ + g++-multilib + DEBIAN_FRONTEND=noninteractive \ + apt-get install -y \ + crossbuild-essential-armhf + + # download arm-none-eabi + wget "https://developer.arm.com/-/media/Files/downloads/gnu-rm/10-2020q4/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2?revision=ca0cbf9c-9de2-491c-ac48-898b5bbc0443&la=en&hash=68760A8AE66026BCF99F05AC017A6A50C6FD832A" -O /tmp/arm.tar.bz2 && \ + tar -jxvf /tmp/arm.tar.bz2 -C /opt && \ + mv /opt/gcc-arm-none-eabi-10-2020-q4-major /opt/tools + + # install cbc_llvm + hg clone http://www.cr.ie.u-ryukyu.ac.jp/hg/CbC/CbC_llvm/ + mkdir -p /usr/local/cbc_llvm + mkdir -p /CbC_llvm/builddir + cd /CbC_llvm/builddir + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_DOCS=OFF -DLLVM_ENABLE_PROJECTS="clang;lld" \ + -DCMAKE_INSTALL_PREFIX=/usr/local/cbc_llvm -DCMAKE_CROSSCOMPILING=True \ + /CbC_llvm/llvm + ninja + ninja install + +%environment + CC=/usr/local/cbc_llvm/bin/clang + CXX=/usr/local/cbc_llvm/bin/clang++ + LLVM_DIR=CbC_llvm + export CC CXX LLVM_DIR + export PATH=/usr/local/cbc_llvm/bin:$PATH \ No newline at end of file