From 036ce4b42c092bfb79b4a262982adff071076aea Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 20 Jun 2014 15:19:33 -0400 Subject: [PATCH] abstract_compiler: remove -lunwind if target is Darwin (macosx) --- src/abstract_compiler.nit | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/abstract_compiler.nit b/src/abstract_compiler.nit index 0f4070c..e8d0179 100644 --- a/src/abstract_compiler.nit +++ b/src/abstract_compiler.nit @@ -320,19 +320,28 @@ class MakefileToolchain if libs != null then linker_options.add_all(libs) end - var ost = toolcontext.opt_stacktrace.value - if ost == "libunwind" or ost == "nitstack" then linker_options.add("-lunwind") - makefile.write("CC = ccache cc\nCFLAGS = -g -O2 -Wno-unused-value -Wno-switch\nCINCL = {cc_includes}\nLDFLAGS ?= \nLDLIBS ?= -lm -lgc {linker_options.join(" ")}\n\n") + var ost = toolcontext.opt_stacktrace.value + if ost == "libunwind" or ost == "nitstack" then makefile.write("NEED_LIBUNWIND := YesPlease\n") + # Dynamic adaptations # While `platform` enable complex toolchains, they are statically applied # For a dynamic adaptsation of the compilation, the generated Makefile should check and adapt things itself + # Check and adapt the targeted system + makefile.write("uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n") + makefile.write("ifeq ($(uname_S),Darwin)\n") + # remove -lunwind since it is already included on macosx + makefile.write("\tNEED_LIBUNWIND :=\n") + makefile.write("endif\n\n") + # Check and adapt for the compiler used # clang need an additionnal `-Qunused-arguments` makefile.write("clang_check := $(shell sh -c '$(CC) -v 2>&1 | grep -q clang; echo $$?')\nifeq ($(clang_check), 0)\n\tCFLAGS += -Qunused-arguments\nendif\n") + makefile.write("ifdef NEED_LIBUNWIND\n\tLDLIBS += -lunwind\nendif\n") + makefile.write("all: {outpath}\n\n") var ofiles = new Array[String] -- 1.7.9.5