From 9c70a7cf23d11d2fc568a56ef04a709eefc51456 Mon Sep 17 00:00:00 2001 From: Heshan Padmasiri Date: Thu, 23 Nov 2023 10:23:41 +0530 Subject: [PATCH] Add a "release" build target to jni.llvm (#1241) * Fix incremental builds Cleanup build script Cleaned resource config Update the README Add Ballerina config for Aarch64 Refactor Makefile Add dist targets for jar and native compilers * Fix jar only build not including runtime * Implement cross compilation * Allow running the script from any directory * Fix incremental builds * Change gzip to xz * Fix target * Change the cross compiler to gcc * Fix file name * Fix aarch64 builds Some of the cases where we were using GEPs don't work in aarch64 (most likely due to clang packing values differently). Workaround this by adding inlinable functions to access values * Fix build scripts to use only sh * Fix build script search depth * Fix runner for OSX * Fix naming * Revert "Fix aarch64 builds" This reverts commit f594e86acf2c7caa8d75a4d884e86ff2de1faaba. * Change compilation scripts to use bash * Fix bash scripts --- llvm_jni/BallerinaDarwinAArch64.toml | 24 ++++ llvm_jni/BallerinaLinuxAArch64.toml | 24 ++++ ...uxX86_64.toml => BallerinaLinuxAMD64.toml} | 0 llvm_jni/Makefile | 110 +++++++++++++----- llvm_jni/README.md | 48 ++++---- llvm_jni/dist/jvm/README.md | 12 ++ llvm_jni/dist/jvm/nballerina.sh | 28 +++++ llvm_jni/dist/native/README.md | 18 +++ llvm_jni/dist/native/nballerina.sh | 47 ++++++++ llvm_jni/jniConfigGen.py | 9 +- llvm_jni/modules/jni.llvm/Module.bal | 15 ++- llvm_jni/resource_config.json | 8 +- runtime/Makefile | 19 +-- 13 files changed, 287 insertions(+), 75 deletions(-) create mode 100644 llvm_jni/BallerinaDarwinAArch64.toml create mode 100644 llvm_jni/BallerinaLinuxAArch64.toml rename llvm_jni/{BallerinaLinuxX86_64.toml => BallerinaLinuxAMD64.toml} (100%) create mode 100644 llvm_jni/dist/jvm/README.md create mode 100644 llvm_jni/dist/jvm/nballerina.sh create mode 100644 llvm_jni/dist/native/README.md create mode 100644 llvm_jni/dist/native/nballerina.sh diff --git a/llvm_jni/BallerinaDarwinAArch64.toml b/llvm_jni/BallerinaDarwinAArch64.toml new file mode 100644 index 000000000..7390066c2 --- /dev/null +++ b/llvm_jni/BallerinaDarwinAArch64.toml @@ -0,0 +1,24 @@ +[package] +org = "wso2" +name = "nballerina" +version = "0.1.0" +[build-options] +observabilityIncluded = false + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-platform-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-1.5.9-macosx-arm64.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-16.0.4-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-platform-16.0.4-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-16.0.4-1.5.9-macosx-arm64.jar" diff --git a/llvm_jni/BallerinaLinuxAArch64.toml b/llvm_jni/BallerinaLinuxAArch64.toml new file mode 100644 index 000000000..63912f39f --- /dev/null +++ b/llvm_jni/BallerinaLinuxAArch64.toml @@ -0,0 +1,24 @@ +[package] +org = "wso2" +name = "nballerina" +version = "0.1.0" +[build-options] +observabilityIncluded = false + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-platform-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/javacpp-1.5.9-linux-arm64.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-16.0.4-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-platform-16.0.4-1.5.9.jar" + +[[platform.java11.dependency]] +path = "target/platform-libs/llvm-16.0.4-1.5.9-linux-arm64.jar" diff --git a/llvm_jni/BallerinaLinuxX86_64.toml b/llvm_jni/BallerinaLinuxAMD64.toml similarity index 100% rename from llvm_jni/BallerinaLinuxX86_64.toml rename to llvm_jni/BallerinaLinuxAMD64.toml diff --git a/llvm_jni/Makefile b/llvm_jni/Makefile index 366582798..07800d936 100644 --- a/llvm_jni/Makefile +++ b/llvm_jni/Makefile @@ -1,12 +1,45 @@ +LLVM_SUFFIX?=-16 COMBINED_SRC_DIR=../testbuild COMPILER_DIR=../compiler +SUBSET_DOC=../docs/subset15.md COMPILER_SRC=$(wildcard $(COMPILER_DIR)/*.bal) $(wildcard $(COMPILER_DIR)/modules/*/*.bal) +PRINT_LLVM_SRC=$(wildcard $(COMPILER_DIR)/modules/print.llvm/*.bal) $(COMPILER_DIR)/output.bal +COMBINED_SRC=$(subst $(COMPILER_DIR),$(COMBINED_SRC_DIR),$(filter-out $(PRINT_LLVM_SRC), $(COMPILER_SRC))) JNI_SRC=$(wildcard ./modules/jni.llvm/*.bal) INLINE_RUNTIME=../runtime/balrt_inline.bc +RUNTIME=../runtime/balrt.a DEPENDECIES_DIR=$(COMBINED_SRC_DIR)/target/platform-libs -COMPILER_JAR=$(COMBINED_SRC_DIR)/target/nballerina.jar -NATIVE_EXE=$(COMBINED_SRC_DIR)/target/nballerina -BAL_CONFIG=Ballerina.toml +BASE_JAR=$(COMBINED_SRC_DIR)/target/bin/nballerina_base.jar +COMPILER_JAR=$(COMBINED_SRC_DIR)/target/bin/nballerina.jar +COMPILER_NATIVE=$(COMBINED_SRC_DIR)/target/bin/nballerina +AARCH64_RUNTIME=$(COMBINED_SRC_DIR)/target/bin/balrt_aarch64.a +AARCH64_INLINE_RUNTIME=$(COMBINED_SRC_DIR)/target/bin/balrt_inline_aarch64.bc +BAL_CONFIG?=Ballerina.toml +GENERATED_CONFIGS=jni_config.json reflection_config.json +REFLECTION_CONFIG=../../../llvm_jni/reflection_config.json +JNI_CONFIG=../../../llvm_jni/jni_config.json,../../../llvm_jni/jni_workaround.json +RESOURCE_CONFIG=../../../llvm_jni/resource_config.json +NATIVE_IMAGE_FLAGS?=--no-fallback -H:+StaticExecutableWithDynamicLibC -H:MaxDuplicationFactor=75 \ + -H:ResourceConfigurationFiles=$(RESOURCE_CONFIG) -H:ReflectionConfigurationFiles=$(REFLECTION_CONFIG) \ + -H:JNIConfigurationFiles=$(JNI_CONFIG) +MVN?=mvn +VERSION=0.1 +SYSTEM?=linux +ARCH?=amd64 +DIST_NAME=nballerina.$(VERSION)-$(SYSTEM)-$(ARCH) +DIST_DIR=../build/$(DIST_NAME) +DIST_AR=../build/$(DIST_NAME).tar.xz +ifeq ($(ARCH), amd64) + DIST_INLINE_RUNTIME=$(AARCH64_INLINE_RUNTIME) $(INLINE_RUNTIME) + DIST_RUNTIME=$(RUNTIME) $(AARCH64_RUNTIME) + DIST_COMPILER=$(COMPILER_NATIVE) + DIST_BASE_DIR=./dist/native +else + DIST_INLINE_RUNTIME= $(INLINE_RUNTIME) + DIST_RUNTIME=$(RUNTIME) + DIST_COMPILER=$(COMPILER_JAR) + DIST_BASE_DIR=./dist/jvm +endif # Finished copying jar files of dependencies DEPENDENCIES_STAMP=$(COMBINED_SRC_DIR)/dependencies.stamp @@ -17,54 +50,77 @@ JNI_STAMP=$(COMBINED_SRC_DIR)/jni.stamp # Added inline runtime to the nballerina.jar file RUNTIME_STAMP=$(COMBINED_SRC_DIR)/runtime.stamp +all: $(COMPILER_NATIVE) + +$(GENERATED_CONFIGS): jniConfigGen.py $(JNI_SRC) + python3 jniConfigGen.py $(JNI_SRC) + $(DEPENDENCIES_STAMP):pom.xml $(COMPILER_STAMP) $(JNI_STAMP) -rm -rf $(DEPENDECIES_DIR) - mvn -U compile + $(MVN) -U compile mkdir -p $(DEPENDECIES_DIR) find ~/.m2/repository/org/bytedeco -name "*.jar" -exec cp "{}" $(DEPENDECIES_DIR) \; @touch $@ -$(COMPILER_STAMP): $(COMPILER_SRC) - mkdir -p $(COMBINED_SRC_DIR) - cp -r $(COMPILER_DIR)/* $(COMBINED_SRC_DIR) - find $(COMBINED_SRC_DIR) -type f -name "*.bal" -exec sed -i 's/print.llvm/jni.llvm/g' {} \; - rm -rf $(COMBINED_SRC_DIR)/modules/print.llvm - rm $(COMBINED_SRC_DIR)/output.bal +$(COMBINED_SRC_DIR)/%.bal: $(COMPILER_DIR)/%.bal + mkdir -p $(@D) + sed 's/print.llvm/jni.llvm/g' $< > $@ + +$(COMPILER_STAMP): $(COMBINED_SRC) @touch $@ +$(AARCH64_RUNTIME) $(AARCH64_INLINE_RUNTIME): + $(MAKE) -C ../runtime clean + $(MAKE) -C ../runtime TARGET="-target aarch64-linux-gnu" dist + mv $(RUNTIME) $(AARCH64_RUNTIME) + mv $(INLINE_RUNTIME) $(AARCH64_INLINE_RUNTIME) + $(MAKE) -C ../runtime clean + $(JNI_STAMP): $(COMPILER_STAMP) $(JNI_SRC) cp -r ./modules/jni.llvm $(COMBINED_SRC_DIR)/modules cp output.bal $(COMBINED_SRC_DIR) cp $(BAL_CONFIG) $(COMBINED_SRC_DIR)/Ballerina.toml @touch $@ -$(INLINE_RUNTIME): - $(MAKE) -C ../runtime all +$(DIST_DIR): $(DIST_COMPILER) $(DIST_RUNTIME) $(RUNTIME_STAMP) + rm -rf $(DIST_DIR) + mkdir -p $(DIST_DIR) + cp $(DIST_RUNTIME) $(DIST_DIR) + cp $(DIST_COMPILER) $(DIST_DIR)/compiler$(suffix $(DIST_COMPILER)) + cp $(DIST_BASE_DIR)/* $(DIST_DIR) + cp $(SUBSET_DOC) $(DIST_DIR)/subset.md + chmod +x $(DIST_DIR)/nballerina.sh -$(RUNTIME_STAMP): $(INLINE_RUNTIME) $(COMPILER_JAR) +$(RUNTIME_STAMP): $(DIST_INLINE_RUNTIME) $(BASE_JAR) + cp $(BASE_JAR) $(COMPILER_JAR) cp $(INLINE_RUNTIME) $(COMBINED_SRC_DIR)/target/bin - cd $(COMBINED_SRC_DIR)/target/bin; jar uf nballerina.jar balrt_inline.bc - rm $(COMBINED_SRC_DIR)/target/bin/balrt_inline.bc + cd $(COMBINED_SRC_DIR)/target/bin; jar uf nballerina.jar *.bc + cd $(COMBINED_SRC_DIR)/target/bin; zip -d nballerina.jar ./META-INF/native-image/* @touch $@ -$(NATIVE_EXE): $(COMPILER_JAR) $(RUNTIME_STAMP) - cd $(COMBINED_SRC_DIR)/target/bin; zip -d nballerina.jar ./META-INF/native-image/* - find ./modules/jni.llvm -maxdepth 1 -name "*.bal"| xargs python3 jniConfigGen.py - cd $(COMBINED_SRC_DIR)/target/bin; native-image --no-fallback -H:MaxDuplicationFactor=100 -H:ResourceConfigurationFiles=../../../llvm_jni/resource_config.json -H:ReflectionConfigurationFiles=../../../llvm_jni/reflection_config.json -H:JNIConfigurationFiles=../../../llvm_jni/jni_config.json,../../../llvm_jni/jni_workaround.json -jar nballerina.jar +$(COMPILER_NATIVE): $(COMPILER_JAR) $(RUNTIME_STAMP) $(GENERATED_CONFIGS) + cd $(COMBINED_SRC_DIR)/target/bin; native-image $(NATIVE_IMAGE_FLAGS) -jar nballerina.jar -$(COMPILER_JAR): $(DEPENDENCIES_STAMP) $(COMPILER_STAMP) $(JNI_STAMP) - cd $(COMBINED_SRC_DIR); bal build --offline +$(COMPILER_JAR): $(BASE_JAR) $(RUNTIME_STAMP) -test: $(DEPENDENCIES_STAMP) $(COMPILER_STAMP) $(JNI_STAMP) - cd $(COMBINED_SRC_DIR); bal test --offline --tests nballerina:testCompileVPO +$(BASE_JAR): $(DEPENDENCIES_STAMP) $(COMPILER_STAMP) $(JNI_STAMP) + cd $(COMBINED_SRC_DIR); bal build --offline + mv $(COMPILER_JAR) $(BASE_JAR) -build: $(COMPILER_JAR) +$(RUNTIME) $(INLINE_RUNTIME): + $(MAKE) -C ../runtime dist -buildWithRuntime: $(RUNTIME_STAMP) +%.tar.xz: % + tar -cJf $@ -C $(@D) $(` in `test` directory. diff --git a/llvm_jni/dist/jvm/README.md b/llvm_jni/dist/jvm/README.md new file mode 100644 index 000000000..10f259a34 --- /dev/null +++ b/llvm_jni/dist/jvm/README.md @@ -0,0 +1,12 @@ +# nBallerina:0.1 +Compiler for the [Ballerina language](https://ballerina.io/) that can generate native executables. + +## Requirements ++ Make sure you have Java 17 or later and `java` command is working. ++ Compiler uses the operating system's C compiler (`cc`) for linking. + +## Usage +Run `nballerina.sh ` to compile. Resulting executable (along with build artifacts) will be in `./build` directory + +## Language restrictions +Currently supported subset of the language is defined in `subset.md` file. diff --git a/llvm_jni/dist/jvm/nballerina.sh b/llvm_jni/dist/jvm/nballerina.sh new file mode 100644 index 000000000..45f4ec920 --- /dev/null +++ b/llvm_jni/dist/jvm/nballerina.sh @@ -0,0 +1,28 @@ +#!/bin/sh +set -e +if [ $# -ne 1 ]; then + echo "Error: expected $0 " + exit 1 +fi + +if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + echo "Usage: $0 " + exit 0 +fi + +scriptDir=$(realpath $(dirname "$0")) +src="$1" +buildDir="$(pwd)/build" +runtime="$scriptDir/balrt.a" +mkdir -p "$buildDir" + +java -jar "$scriptDir/./compiler.jar" --outDir "$buildDir" "$src" + +srcName=$(basename "$src" .bal) +cd "$buildDir" +objects=() +for f in "$srcName"*.o; do + objects+=("$buildDir/$f") +done + +cc -O2 -o "$srcName" "$buildDir/$srcName"*.o -lm "$runtime" diff --git a/llvm_jni/dist/native/README.md b/llvm_jni/dist/native/README.md new file mode 100644 index 000000000..0bae42048 --- /dev/null +++ b/llvm_jni/dist/native/README.md @@ -0,0 +1,18 @@ +# nBallerina:0.1 +Compiler for the [Ballerina language](https://ballerina.io/) that can generate native executables. + +## Requirements ++ Compiler uses the operating system's C compiler (`cc`) for linking. + +## Usage +Run `nballerina.sh ` to compile. Resulting executable (along with build artifacts) will be in `./build` directory + +### Cross compiling +Only supported target is `aarch64-linux-gnu`. In order to cross compile first install GCC cross compiler for aarch64. +``` +sudo apt-get install gcc-aarch64-linux-gnu +``` +Then run `nballerina.sh --target aarch64` + +## Language restrictions +Currently supported subset of the language is defined in `subset.md` file. diff --git a/llvm_jni/dist/native/nballerina.sh b/llvm_jni/dist/native/nballerina.sh new file mode 100644 index 000000000..3b94b11f9 --- /dev/null +++ b/llvm_jni/dist/native/nballerina.sh @@ -0,0 +1,47 @@ +#!/bin/sh +set -e + +print_usage_and_exit() { + echo "Usage: $0 [--target aarch64]" + exit "$1" +} + +if [ $# -lt 1 ]; then + print_usage_and_exit 1 +fi + +if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + print_usage_and_exit 0 +fi + +scriptDir=$(realpath $(dirname "$0")) +src="$1" +buildDir="$(pwd)/build" +rm -rf "$buildDir" +mkdir -p "$buildDir" + +c_compiler=cc +runtime="$scriptDir/balrt.a" +if [ $# -gt 1 ]; then + if [ "$2" = "--target" ]; then + if [ $# -lt 3 ]; then + print_usage_and_exit 1 + fi + if [ "$3" = "aarch64" ]; then + "$scriptDir/./compiler" --outDir "$buildDir" --target aarch64-unknown-linux-gnu "$src" + c_compiler=aarch64-linux-gnu-gcc + runtime="$scriptDir/balrt_aarch64.a" + else + echo "Error: unsupported target $3" + exit 1 + fi + else + print_usage_and_exit 1 + fi +else + "$scriptDir"/./compiler --outDir "$buildDir" "$src" +fi + +srcName=$(basename "$src" .bal) + +"$c_compiler" -O2 -static -o "$srcName" "$buildDir/$srcName"*.o -lm "$runtime" diff --git a/llvm_jni/jniConfigGen.py b/llvm_jni/jniConfigGen.py index 7dc62e3bb..e2291b8fb 100644 --- a/llvm_jni/jniConfigGen.py +++ b/llvm_jni/jniConfigGen.py @@ -30,7 +30,8 @@ "org.bytedeco.llvm.LLVM.LLVMOrcCLookupSetElement", "org.bytedeco.llvm.LLVM.LLVMOrcCLookupSetElement", "org.bytedeco.llvm.LLVM.LLVMOrcCSymbolsList", - "org.bytedeco.llvm.LLVM.LLVMOrcCSymbolAliasMapEntry" + "org.bytedeco.llvm.LLVM.LLVMOrcCSymbolAliasMapEntry", + "org.bytedeco.javacpp.Pointer$NativeDeallocator" ] @@ -75,17 +76,11 @@ def get_default_reflection_config_with_name(self, name): return { "name": name, "queryAllPublicConstructors": True, - "queryAllDeclaredConstructors": True, "queryAllPublicMethods": True, - "queryAllDeclaredMethods": True, "allPublicConstructors": True, - "allDeclaredConstructors": True, "allPublicMethods": True, - "allDeclaredMethods": True, "allPublicFields": True, - "allDeclaredFields": True, "allPublicClasses": True, - "allDeclaredClasses": True } diff --git a/llvm_jni/modules/jni.llvm/Module.bal b/llvm_jni/modules/jni.llvm/Module.bal index 3c4e2f0ee..c04b6ad31 100644 --- a/llvm_jni/modules/jni.llvm/Module.bal +++ b/llvm_jni/modules/jni.llvm/Module.bal @@ -94,7 +94,7 @@ public distinct class Module { function linkInlineLibrary() { LLVMMemoryBuffer runtimeMemBuffer = new; - runtimeMemBuffer.storeResource("balrt_inline.bc"); + runtimeMemBuffer.storeResource(self.pickRuntime()); Module libModule = new("balrt_inline", self.context); libModule.parseBitCode(runtimeMemBuffer); int result = jLLVMLinkModules2(self.LLVMModule, libModule.LLVMModule); @@ -103,6 +103,17 @@ public distinct class Module { } } + private function pickRuntime() returns string { + TargetTriple? targetTriple = self.targetTriple; + if targetTriple == () { + return "balrt_inline.bc"; + } + else if targetTriple is "aarch64-linux-gnu"|"aarch64-unknown-linux-gnu" { + return "balrt_inline_aarch64.bc"; + } + panic error("Only aarch64-linux-gnu supported as a cross compilation target"); + } + // Corresponds to LLVMParseBitcodeInContext2 function parseBitCode(LLVMMemoryBuffer memoryBuffer) { int result = jLLVMParseBitcodeInContext2(self.context.LLVMContext, memoryBuffer.jObject, self.LLVMModule); @@ -113,7 +124,7 @@ public distinct class Module { public function printModuleToObjectFile(string fileName, *ObjectFileGenOptions opts) returns io:Error? { self.finalizeDIBuilder(); - self.linkInlineLibrary(); + self.linkInlineLibrary(); string optLevel = opts.optLevel ?: "Default"; // We are defaulting to PIC (Position Independent Code) since clang defaults to PIE (Position Independent Executable) string relocMode = opts.relocMode ?: "PIC"; diff --git a/llvm_jni/resource_config.json b/llvm_jni/resource_config.json index 61b01fde5..81382b4d6 100644 --- a/llvm_jni/resource_config.json +++ b/llvm_jni/resource_config.json @@ -1,7 +1,9 @@ { "resources": [ - {"pattern": "org/*"}, - {"pattern": ".*/*.so.*"}, - {"pattern": "balrt_inline.bc" } + {"pattern": ".*/*.so"}, + {"pattern": ".*/*.so.16"}, + {"pattern": ".*/*.properties"}, + {"pattern": "balrt_inline.bc"}, + {"pattern": "balrt_inline_aarch64.bc"} ] } diff --git a/runtime/Makefile b/runtime/Makefile index c8eca4205..110fcfcc6 100644 --- a/runtime/Makefile +++ b/runtime/Makefile @@ -4,6 +4,7 @@ LLVM_AS ?= llvm-as$(LLVM_SUFFIX) OPT ?= opt$(LLVM_SUFFIX) export CFLAGS ?= -O2 export LLVM_LINK ?= llvm-link$(LLVM_SUFFIX) +TARGET ?= VALGRIND ?= valgrind WARN_FLAGS=-Wextra -Wall BT_WARN_FLAGS=-W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual @@ -30,6 +31,8 @@ export BCLIB=balrt_inline.bc all: $(LIB) $(BCLIB) $(MAKE) -C tests all +dist: $(LIB) $(BCLIB) + test: all $(MAKE) -C tests test @@ -48,17 +51,17 @@ $(BCLIB): $(BCS) $(LLVM_AS) >$@ $(BT_OBJS): %.o: %.c - $(CLANG) -DHAVE_CONFIG_H -funwind-tables -frandom-seed=$< $(BT_WARN_FLAGS) $(CFLAGS) -c -o $@ $< + $(CLANG) -DHAVE_CONFIG_H $(TARGET) -funwind-tables -frandom-seed=$< $(BT_WARN_FLAGS) $(CFLAGS) -c -o $@ $< $(DTOA_OBJS) $(DN_OBJS): %.o: %.c - $(CLANG) $(DEFINES) $(CFLAGS) -c -o $@ $< + $(CLANG) $(DEFINES) $(CFLAGS) $(TARGET) -c -o $@ $< %.o: %.bc - $(CLANG) -O2 -c -o $@ $< + $(CLANG) -O2 $(TARGET) -c -o $@ $< %.bc: %.c $(LL_BCS) set -o pipefail; \ - $(CLANG) -c $(CFLAGS) $(DEFINES) $(WARN_FLAGS) -emit-llvm -o - $< | \ + $(CLANG) -c $(CFLAGS) $(TARGET) $(DEFINES) $(WARN_FLAGS) -emit-llvm -o - $< | \ $(LLVM_LINK) $(LL_BCS) - -o - -S | \ sed -e '/define .*@_bal_ptr_mask/s/^define /define linkonce_odr /' \ -e '/define .*@_bal_float_eq/s/^define /define linkonce_odr /' \ @@ -71,15 +74,15 @@ $(DTOA_OBJS) $(DN_OBJS): %.o: %.c %.o: %.c %.o: %.ll - $(CLANG) -O2 -c -o $@ $< + $(CLANG) -O2 $(TARGET) -c -o $@ $< # we have to use -O2 here, otherwise the function will get a noinline attribute $(C_BCS): %.bc: %.c - $(CLANG) $(CFLAGS) $(WARN_FLAGS) -c -O2 -emit-llvm -o $@ $< + $(CLANG) $(CFLAGS) $(TARGET) $(WARN_FLAGS) -c -O2 -emit-llvm -o $@ $< $(LL_BCS): %.bc: %.ll set -o pipefail; \ - $(CLANG) -x c /dev/null -emit-llvm -S -o - | grep "^target" | cat - $< | $(LLVM_AS) - -o=$@ + $(CLANG) $(TARGET) -x c /dev/null -emit-llvm -S -o - | grep "^target" | cat - $< | $(LLVM_AS) - -o=$@ $(RT_OBJS) $(BCS): $(INCLUDES) @@ -87,7 +90,7 @@ clean: -rm -f $(OBJS) $(BCS) $(LIB) $(BCLIB) $(MAKE) -C tests clean -.PHONY: test all +.PHONY: test all dist # Ensure bogus files get deleted when there's an error .DELETE_ON_ERROR: