From 73a4c395d2efa1a4802ccd0e1efff31da6ed1b97 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Tue, 3 Dec 2019 21:00:59 -0600 Subject: [PATCH] Address #190 We don't ever invoke ld directly, so ignore --linker on non-windows. For --compiler and --archiver, default to $CC and $AR. These are overshadowed by CLI flags or settings in project.janet. --- auxbin/jpm | 19 ++++++++++--------- jpm.1 | 11 ++++++----- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/auxbin/jpm b/auxbin/jpm index 5d991a18..64f1e011 100755 --- a/auxbin/jpm +++ b/auxbin/jpm @@ -108,9 +108,9 @@ # Compilation Defaults # -(def default-compiler (if is-win "cl" "cc")) -(def default-linker (if is-win "link" "cc")) -(def default-archiver (if is-win "lib" "ar")) +(def default-compiler (or (os/getenv "CC") (if is-win "cl.exe" "cc"))) +(def default-linker (or (os/getenv "CC") (if is-win "link.exe" "cc"))) +(def default-archiver (or (os/getenv "AR") (if is-win "lib.exe" "ar"))) # Default flags for natives, but not required (def default-lflags (if is-win ["/nologo"] [])) @@ -312,7 +312,7 @@ (defn- link-c "Link object files together to make a native module." [opts target & objects] - (def ld (opt opts :linker default-linker)) + (def linker (opt opts (if is-win :linker :compiler) default-linker)) (def cflags (getcflags opts)) (def lflags [;(opt opts :lflags default-lflags) ;(if (opts :static) [] dynamic-lflags)]) @@ -320,8 +320,8 @@ (check-cc) (print "linking " target "...") (if is-win - (shell ld ;lflags (string "/OUT:" target) ;objects (win-import-library)) - (shell ld ;cflags `-o` target ;objects ;lflags)))) + (shell linker ;lflags (string "/OUT:" target) ;objects (win-import-library)) + (shell linker ;cflags `-o` target ;objects ;lflags)))) (defn- archive-c "Link object files together to make a static library." @@ -858,9 +858,10 @@ Keys are: --headerpath : The directory containing janet headers. Defaults to $JANET_HEADERPATH. --binpath : The directory to install binaries and scripts. Defaults to $JANET_BINPATH. --libpath : The directory containing janet C libraries (libjanet.*). Defaults to $JANET_LIBPATH. - --compiler : C compiler to use for natives. Defaults to cc (cl on windows). - --archiver : C compiler to use for static libraries. Defaults to ar (lib on windows). - --linker : C linker to use for linking natives. Defaults to cc (link on windows). + --compiler : C compiler to use for natives. Defaults to $CC or cc (cl.exe on windows). + --archiver : C compiler to use for static libraries. Defaults to $AR ar (lib.exe on windows). + --linker : C linker to use for linking natives. Defaults to link.exe on windows, not used on + other platforms. --pkglist : URL of git repository for package listing. Defaults to $JANET_PKGLIST or https://github.com/janet-lang/pkgs.git Flags are: diff --git a/jpm.1 b/jpm.1 index 809875a3..e31c1ef6 100644 --- a/jpm.1 +++ b/jpm.1 @@ -60,23 +60,24 @@ Linking statically might be a better idea, even in that case. Defaults to $JANET_LIBPATH, or a reasonable default. See JANET_LIBPATH for more. .TP -.BR \-\-compiler=cc +.BR \-\-compiler=$CC Sets the compiler used for compiling native modules and standalone executables. Defaults to cc. .TP -.BR \-\-linker=ld -Sets the linker used to create native modules and executables. +.BR \-\-linker +Sets the linker used to create native modules and executables. Only used on windows, where +it defaults to link.exe. .TP .BR \-\-pkglist=https://github.com/janet-lang/pkgs.git Sets the git repository for the package listing used to resolve shorthand package names. .TP -.BR \-\-archiver=ar +.BR \-\-archiver=$AR Sets the command used for creating static libraries, use for linking into the standalone executable. Native modules are compiled twice, once a normal native module (shared object), and once as an -archive. +archive. Defaults to ar. .SH COMMANDS .TP