From e926c569d7d68e1b3db049c01e2d70f29f6bb1da Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 10 Feb 2012 15:35:22 -0500 Subject: [PATCH] tools: put libs after objects MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Extern libs (given by --cc-lib-name) should also appears after the objects. Signed-off-by: Alexis Laferrière --- bin/gccx | 7 +++++-- src/compiling/compiling_base.nit | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/gccx b/bin/gccx index 3f2890d..8159f30 100755 --- a/bin/gccx +++ b/bin/gccx @@ -19,6 +19,7 @@ OPTS="-g" # option for compiler call objs="" # List of .o files +libs="" CC="cc" # Default compiler call ext="_savo _sav" # Default flavor to reuse out="a.out" # Default output binary filename @@ -35,6 +36,7 @@ Usage: $e [options] modulename [options for module execution] -R Force full recompilation -O Compile with optimizations -i Use the intel compiler instead of gcc +-l C library to link with -ll Use the clang compiler (llvm) instead of gcc -I path Add a include directory -o name Call name the executable @@ -79,6 +81,7 @@ while [ $stop = false ]; do -R) recompile=true; shift;; -O) OPTS="$OPTS -O2" ext="_savo"; shift;; -i) CC="/opt/intel/cc/10.1.015/bin/icc -O2" ext="_savi"; shift;; + -l) libs="$libs -l$2"; shift;; -ll) CC="clang --ansi --pedantic -O3"; ext="_savll"; shift;; -I) OPTS="$OPTS -I $2"; shift; shift;; -o) out="$2"; shift; shift;; @@ -158,6 +161,6 @@ fi done if [ $vverbose = true ] ; then - echo "* $CC $OPTS $objs -lm -o $out" >&2 + echo "* $CC $OPTS $objs -lm $libs -o $out" >&2 fi -$CC $OPTS $objs -lm -o "$out" +$CC $OPTS $objs -lm $libs -o "$out" diff --git a/src/compiling/compiling_base.nit b/src/compiling/compiling_base.nit index a53a4e2..d90e883 100644 --- a/src/compiling/compiling_base.nit +++ b/src/compiling/compiling_base.nit @@ -106,7 +106,7 @@ class CProgram end if tc.boost then f.write(" -O") if not tc.cc_link then f.write(" -x \"-c\"") - for l in tc.cc_libs do f.write(" -x \"-l {l}\"") + for l in tc.cc_libs do f.write(" -l {l}") for lp in tc.cc_lib_paths do f.write(" -x \"-L {lp}\"") for ip in tc.cc_include_paths do f.write(" -x \"-I {ip}\"") f.write(" \"$@\" \\\n {files.join("\\\n ")}\n") -- 1.7.9.5