Giter Club home page Giter Club logo

p2llvm's Introduction

Propeller 2 LLVM Libraries

Contains Propeller 2 Library, C Standard Library, examples, and documentation for p2llvm

Getting Started

(eventually I'll make a docker image that has all dependnecies set up so building is a simple one-step process)

  1. Make sure you have the reuqired dependancies listed here https://llvm.org/docs/GettingStarted.html#software
  2. Initialize the llvm-project submodule in this repo.
git submodule init
git submodule update
  1. Create a build folder in llvm-project and change to it:
mkdir build & cd build
  1. Configure the project for building. This gives the basic configuration and creates Makefiles. See https://llvm.org/docs/GettingStarted.html for details on this command
cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/p2llvm -DLLVM_ENABLE_PROJECTS="lld;clang" -DCMAKE_BUILD_TYPE=Release -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=P2 -DLLVM_TARGETS_TO_BUILD="" ../llvm-project/llvm

Make install dir something like /opt/p2llvm

  1. Once configured, run
make -j8

(replace 8 with how many cores you want to use). Make a sandwich, initial build took around 30 minutes on my 4-core i7 Macbook.

  1. Install, if desired
make install

Building Projects

Building C/C++ code with this compile suite works like any other. Compile each source file into a .o, link them all together with ld. Below are the specific details on this. Eventually, libp2, libc, and the linker script will all be automagically included by clang, that's on the todo list. Chances are you already have clang installed on your computer (expecially if on macOS), so be sure to set up you builds to use the above install directory and not your system clang.

  1. Compile a source object. I use the following CFLAGS. The ciritcal ones are --target=p2, which tells our clang build what backend to use; -fno-jump-tables (required, see wiki in docs for why); and -Os, which will make code a lot more size and speed efficient. eventually, all necessary options will be automatically added by clang, including the library includes.
CFLAGS = -Os -ffunction-sections -fdata-sections -fno-jump-tables --target=p2
<llvm binaries>/clang $(CFLAGS) -o hello.o -c hello.c
  1. Link your objects into an executable ELF binary.
LFLAGS = -Tp2.ld
<llvm binaries>/ld.lld $(LFLAGS) -o hello.elf hello.o
  1. Load the resulting elf using loadp2
loadp2 -v -ZERO -b 230400 -t hello.elf

p2llvm's People

Contributors

ne75 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.