Skip to content

Instantly share code, notes, and snippets.

@ryankurte
Last active August 31, 2015 03:30
Show Gist options
  • Save ryankurte/118281a322fe38a7f9a6 to your computer and use it in GitHub Desktop.
Save ryankurte/118281a322fe38a7f9a6 to your computer and use it in GitHub Desktop.
Compile Clang/LLVM for cross building

Test with: clang -target arm-none-eabi -mcpu=cortex-m3 --sysroot=~/.env/gcc-arm-none-eabi -c test.c

#!/bin/bash
# Download and compile Clang/LLVM from source
# Exit on any errors
set -e
# Fetch LLVM
mkdir crossllvm
cd crossllvm
git clone http://llvm.org/git/llvm.git
# Fetch Clang
cd llvm/tools
git clone http://llvm.org/git/clang.git
cd ../..
# Fetch runtime
cd llvm/projects
git clone http://llvm.org/git/compiler-rt.git
cd ../..
# Build
mkdir build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE:STRING=Release ../llvm
ninja
#To install run: sudo ninja install
int main(int argc, char** argv) {
while(1);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment