Giter VIP home page Giter VIP logo

xcc's Introduction

XCC

Action Status Open in Gitpod

C compiler running on Linux or MacOS.

  • Supporting architecture: x86-64, aarch64 (arm64), riscv64, wasm
  • Binary format: ELF64

Requirements

  • Linux (or MacOS)
  • C compiler (gcc or clang)
  • make

Build

$ make

Generated files:

  • xcc: Compiler entry
  • cpp: Preprocessor
  • cc1: C compiler
  • as: Assembler
  • ld: Linker

Usage

$ ./xcc -o hello examples/hello.c
$ ./hello
Hello, world!

Command line options

  • -o <filename>: Set output filename (default: a.out)
  • -I <path>: Add include path
  • -D <label>(=value): Define macro
  • -S: Output assembly code
  • -E: Preprocess only
  • -c: Output object file
  • -nodefaultlibs: Ignore libc
  • -nostdlib: Ignore libc and crt0

TODO

  • Optimization
  • Archiver

Reference


WebAssembly

Compile C to WebAssembly/WASI binary.

Online demo

Requirements

  • node.js
  • llvm-ar

Build

$ make wcc

Generated files:

  • wcc: C compiler (including preprocessor, and output .wasm directly)

Usage

Compile:

$ ./wcc -o hello.wasm examples/hello.c

Command line options:

  • -o <filename>: Set output filename (default: a.wasm)
  • -I <path>: Add include path
  • -D <label>(=value): Define macro
  • -c: Output object file
  • --entry-point=func_name: Specify entry point (default: _start)
  • -e func_name,...: Export function names (comma separated)
  • --stack-size=<size>: Set stack size (default: 8192)
  • -nodefaultlibs: Ignore libc
  • -nostdlib: Ignore libc and crt0
  • --verbose: Output debug information

Run

$ ./tool/runwasi hello.wasm
Hello, world!

You can use WASM runtime (Wasmtime, Wasmer, etc.).

Missing features

  • goto statement

xcc's People

Contributors

dependabot[bot] avatar mingodad avatar tyfkda avatar xquantxz avatar zamfofex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

xcc's Issues

constexpr

  • char buf[1 + 2];
  • case 2 * 3:
  • enum { Foo = 1 << 1 };

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.