Skip to content

Commit

Permalink
Merge branch 'release/0.34.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiayang committed Apr 28, 2019
2 parents 67def52 + a389e1c commit 763e87d
Show file tree
Hide file tree
Showing 64 changed files with 1,428 additions and 488 deletions.
20 changes: 20 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: v1.0
name: flax
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
blocks:
- name: "main"
task:
jobs:
- name: main
commands:
- checkout
- echo "LLVM 7"
- sudo echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list
- sudo echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list
- sudo wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
- sudo apt -y update
- sudo apt-get -o Dpkg::Options::="--force-overwrite" --allow-unauthenticated -y install -y llvm-7 llvm-7-dev libllvm7 libmpfr-dev libmpfr6
- CXX=g++-8 CC=gcc-8 LLVM_CONFIG=llvm-config-7 make -j2 test
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ compiler: clang
matrix:
include:
- os: linux
dist: trusty
dist: xenial
sudo: false
- os: osx
osx_image: xcode9.4

addons:
apt:
sources:
- llvm-toolchain-trusty-6.0
- llvm-toolchain-xenial-7
- ubuntu-toolchain-r-test

packages:
- g++-8
- llvm-6.0
- llvm-6.0-dev
- libllvm6.0
- llvm-7
- llvm-7-dev
- libllvm7
- libmpfr-dev
- libmpfr4
homebrew:
packages:
- llvm@6
- llvm@7
update: true

script:
- if [ "$TRAVIS_OS_NAME" == "osx" ];
then PATH="/usr/local/opt/llvm@6/bin:$PATH" LLVM_CONFIG=llvm-config make tester;
else CXX=g++-$GCC_VERSION CC=gcc-$GCC_VERSION make ci;
then PATH="/usr/local/opt/llvm@7/bin:$PATH" LLVM_CONFIG=llvm-config make tester;
else CXX=g++-$GCC_VERSION CC=gcc-$GCC_VERSION LLVM_CONFIG=llvm-config-7 make ci;
fi

notifications:
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,16 @@ do {

### Building the Flax compiler

#### Dependencies ####
- LLVM 7, mostly due to their obsession with changing the IR interface every damn version (6 does not work, 8 does not work)
- GMP/MPIR
- MPFR


#### macOS / Linux

- Flax uses a makefile; most likely some form of GNU-compatible `make` will work.
- LLVM needs to be installed. On macOS, `brew install llvm@6` should work. (note: llvm 7 and up seems to have changed some JIT-related things)
- LLVM needs to be installed. On macOS, `brew install llvm@7` should work. (note: llvm 8 and up seems to have changed some JIT-related things)
- For macOS people, simply call `make`.
- Linux people, call `make linux`.
- A *C++17*-compatible compiler should be used.
Expand Down
8 changes: 6 additions & 2 deletions build/run-test.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ IF /I "%1"=="debugopt" (
)


ninja -C %buildDir% && cls && %buildDir%\flaxc.exe -Ox -sysroot build\sysroot -run build\%2.flx
ninja -C %buildDir% && cls && %buildDir%\flaxc.exe -Ox -sysroot build\sysroot -run build\%2.flx %3 %4

ENDLOCAL
IF /I "%1"=="release" (
copy %buildDir%\flaxc.exe build\sysroot\usr\local\bin\ >NUL
)

ENDLOCAL
66 changes: 66 additions & 0 deletions build/supertiny.flx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,61 @@ import libc as _

// import std::io
// import std::map
import std::opt

@raw union ipv4
{
_: struct {
_: @raw union {
bytes2: [u8: 4]
raw3: u32
}
}

_: struct {
bytes: [u8: 4]
}

_: struct {
raw2: u32
}

raw: u32
}


struct foo
{
x: int
y: str
}

@entry fn main()
{
do {
var addr: ipv4
addr.raw3 = 0xff01a8c0;

printf("%d.%d.%d.%d\n", addr.bytes[0], addr.bytes[1], addr.bytes[2], addr.bytes[3]);
}


/* do {
var x: @raw union {
bar: f64
foo: i64
}

x.bar = 3.14159

printf("x = %.2lf\n", x.bar)
printf("x = %d\n", x.foo)
} */
}




/*

import std::opt
Expand All @@ -36,6 +83,14 @@ import std:: map


/*
!!! bugs (2) !!!
!!! 22/03/19
{
1. we currently check whether you are trying to put a refcounted type as a field of a raw union. however!
you can circumvent this check if you nest the field into inner types, or if you use transparent fields!!
}


! bugs !!!
! 02/12
{
Expand Down Expand Up @@ -96,6 +151,17 @@ import std:: map
even just enforcing that we get either a string literal of exactly length 1, or an i8 type, at compile-time.
sure, we could just abort when passed a slice != length 1, but then why bother being statically typed??
}

16. operator overload errors {
something like this:

failed to resolve candidate for 'operator == (type_1, type_2)'
callsite was here: 'foo == bar'
potential candidates: 'operator == (type_1, type_3)'

ofc potential candidates should be limited to ones where at least one of the types
are similar.
}
*/


Expand Down
10 changes: 5 additions & 5 deletions build/tests/anytest.flx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ var glob: any

struct Large
{
var a: i64
var b: i64
var c: i64
var d: i64
var e: i64
a: i64
b: i64
c: i64
d: i64
e: i64
}

public fn doAnyTest()
Expand Down
6 changes: 3 additions & 3 deletions build/tests/linkedlist.flx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class LinkedList<T>
{
struct Node
{
var prev: &Node
var next: &Node
prev: &Node
next: &Node

var data: T
data: T
}

var head: &Node
Expand Down
4 changes: 3 additions & 1 deletion build/tests/using.flx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ public fn doUsingTest()
}

do {
struct xxx<T>
class xxx<T>
{
init() { }

var k: T
enum Foo: int
{
Expand Down
8 changes: 4 additions & 4 deletions flax.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<AdditionalOptions>/ignore:4099</AdditionalOptions>
</Link>
<Link>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMOrcJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMTD;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AssemblyDebug>true</AssemblyDebug>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
Expand Down Expand Up @@ -150,7 +150,7 @@ rem exit 0</Command>
<AdditionalOptions>/ignore:4099</AdditionalOptions>
</Link>
<Link>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMOrcJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMTD;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AssemblyDebug>false</AssemblyDebug>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
Expand Down Expand Up @@ -193,7 +193,7 @@ rem exit 0</Command>
<AdditionalOptions>/ignore:4099</AdditionalOptions>
</Link>
<Link>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>LLVMCore.lib;LLVMSupport.lib;LLVMTarget.lib;LLVMPasses.lib;LLVMAnalysis.lib;LLVMGlobalISel.lib;LLVMLibDriver.lib;LLVMLinker.lib;LLVMipo.lib;LLVMBinaryFormat.lib;LLVMMC.lib;LLVMMCJIT.lib;LLVMOrcJIT.lib;LLVMMCParser.lib;LLVMMCDisassembler.lib;LLVMObject.lib;LLVMScalarOpts.lib;LLVMVectorize.lib;LLVMCodegen.lib;LLVMTablegen.lib;LLVMBitReader.lib;LLVMBitWriter.lib;LLVMInstrumentation.lib;LLVMRuntimeDyld.lib;LLVMInstCombine.lib;LLVMInterpreter.lib;LLVMExecutionEngine.lib;LLVMSelectionDAG.lib;LLVMTransformUtils.lib;LLVMDebugInfoCodeView.lib;LLVMDebugInfoDWARF.lib;LLVMDebugInfoMSF.lib;LLVMDebugInfoPDB.lib;LLVMAsmPrinter.lib;LLVMX86AsmPrinter.lib;LLVMProfileData.lib;LLVMX86AsmParser.lib;LLVMX86Info.lib;LLVMX86CodeGen.lib;LLVMX86Utils.lib;LLVMX86Desc.lib;LLVMDlltoolDriver.lib;mpfr.lib;mpir.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreSpecificDefaultLibraries>LIBCMTD;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<AssemblyDebug>false</AssemblyDebug>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
Expand Down Expand Up @@ -271,4 +271,4 @@ rem exit 0</Command>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
3 changes: 0 additions & 3 deletions issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ Note: this is just a personal log of outstanding issues, shorter rants/ramblings
3. Optional arguments.


4. Public and private imports (ie. do we re-export our imports (currently the default), or do we keep them to ourselves (the new default)


5. String operators


Expand Down
32 changes: 15 additions & 17 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



WARNINGS := -Wno-unused-parameter -Wno-sign-conversion -Wno-padded -Wno-conversion -Wno-shadow -Wno-missing-noreturn -Wno-unused-macros -Wno-switch-enum -Wno-deprecated -Wno-format-nonliteral -Wno-trigraphs -Wno-unused-const-variable
WARNINGS := -Wno-unused-parameter -Wno-sign-conversion -Wno-padded -Wno-conversion -Wno-shadow -Wno-missing-noreturn -Wno-unused-macros -Wno-switch-enum -Wno-deprecated -Wno-format-nonliteral -Wno-trigraphs -Wno-unused-const-variable -Wno-deprecated-declarations


CLANGWARNINGS := -Wno-undefined-func-template -Wno-comma -Wno-nullability-completeness -Wno-redundant-move -Wno-nested-anon-types -Wno-gnu-anonymous-struct -Wno-reserved-id-macro -Wno-extra-semi -Wno-gnu-zero-variadic-macro-arguments -Wno-shift-sign-overflow -Wno-exit-time-destructors -Wno-global-constructors -Wno-c++98-compat-pedantic -Wno-documentation-unknown-command -Wno-weak-vtables -Wno-c++98-compat
Expand Down Expand Up @@ -38,12 +38,11 @@ CXXDEPS := $(CXXSRC:.cpp=.cpp.d)

NUMFILES := $$(($(words $(CXXSRC)) + $(words $(CSRC))))



DEFINES := -D__USE_MINGW_ANSI_STDIO=1
SANITISE :=

CXXFLAGS += -std=c++1z -O0 -g -c -Wall -frtti -fexceptions -fno-omit-frame-pointer -Wno-old-style-cast $(SANITISE)
CFLAGS += -std=c11 -O0 -g -c -Wall -fno-omit-frame-pointer -Wno-overlength-strings $(SANITISE)
CXXFLAGS += -std=c++1z -O0 -g -c -Wall -frtti -fexceptions -fno-omit-frame-pointer -Wno-old-style-cast $(SANITISE) $(DEFINES)
CFLAGS += -std=c11 -O0 -g -c -Wall -fno-omit-frame-pointer -Wno-overlength-strings $(SANITISE) $(DEFINES)

LDFLAGS += $(SANITISE)

Expand All @@ -64,29 +63,25 @@ TESTSRC := build/tester.flx
-include $(CXXDEPS)


.PHONY: copylibs jit compile clean build osx linux ci prep satest tiny osxflags

prep:
@# echo C++ compiler is: $(CXX)
@mkdir -p $(dir $(OUTPUT))
.PHONY: copylibs jit compile clean build osx linux ci satest tiny osxflags

osxflags: CXXFLAGS += -march=native -fmodules -Weverything -Xclang -fcolor-diagnostics $(SANITISE) $(CLANGWARNINGS)
osxflags: CFLAGS += -fmodules -Xclang -fcolor-diagnostics $(SANITISE) $(CLANGWARNINGS)

osxflags:


osx: prep jit osxflags
osx: jit osxflags

satest: prep osxflags build
satest: osxflags build
@$(OUTPUT) $(FLXFLAGS) -run build/standalone.flx

tester: prep osxflags build
tester: osxflags build
@$(OUTPUT) $(FLXFLAGS) -run build/tester.flx

ci: prep test
ci: test

linux: prep jit
linux: jit

jit: build
@$(OUTPUT) $(FLXFLAGS) -run -o $(SUPERTINYBIN) $(SUPERTINYSRC)
Expand All @@ -100,7 +95,9 @@ test: build
gltest: build
@$(OUTPUT) $(FLXFLAGS) -run -framework GLUT -framework OpenGL -lsdl2 -o $(GLTESTBIN) $(GLTESTSRC)

build: $(OUTPUT) copylibs
build1:

build: build1 $(OUTPUT) copylibs
# built

build/%.flx: build
Expand All @@ -117,7 +114,8 @@ copylibs: $(FLXSRC)

$(OUTPUT): $(PRECOMP_GCH) $(CXXOBJ) $(COBJ)
@printf "# linking\n"
@$(CXX) -o $@ $(CXXOBJ) $(COBJ) $(shell $(LLVM_CONFIG) --cxxflags --ldflags --system-libs --libs core engine native linker bitwriter lto vectorize all-targets object) -lmpfr -lgmp $(LDFLAGS) -lpthread
@mkdir -p $(dir $(OUTPUT))
@$(CXX) -o $@ $(CXXOBJ) $(COBJ) $(shell $(LLVM_CONFIG) --cxxflags --ldflags --system-libs --libs core engine native linker bitwriter lto vectorize all-targets object orcjit) -lmpfr -lgmp $(LDFLAGS) -lpthread


%.cpp.o: %.cpp
Expand Down
Loading

0 comments on commit 763e87d

Please sign in to comment.