1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-29 14:47:42 +00:00
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.
This commit is contained in:
Calvin Rose
2019-12-03 21:00:59 -06:00
parent 70328437f1
commit 73a4c395d2
2 changed files with 16 additions and 14 deletions

View File

@@ -108,9 +108,9 @@
# Compilation Defaults # Compilation Defaults
# #
(def default-compiler (if is-win "cl" "cc")) (def default-compiler (or (os/getenv "CC") (if is-win "cl.exe" "cc")))
(def default-linker (if is-win "link" "cc")) (def default-linker (or (os/getenv "CC") (if is-win "link.exe" "cc")))
(def default-archiver (if is-win "lib" "ar")) (def default-archiver (or (os/getenv "AR") (if is-win "lib.exe" "ar")))
# Default flags for natives, but not required # Default flags for natives, but not required
(def default-lflags (if is-win ["/nologo"] [])) (def default-lflags (if is-win ["/nologo"] []))
@@ -312,7 +312,7 @@
(defn- link-c (defn- link-c
"Link object files together to make a native module." "Link object files together to make a native module."
[opts target & objects] [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 cflags (getcflags opts))
(def lflags [;(opt opts :lflags default-lflags) (def lflags [;(opt opts :lflags default-lflags)
;(if (opts :static) [] dynamic-lflags)]) ;(if (opts :static) [] dynamic-lflags)])
@@ -320,8 +320,8 @@
(check-cc) (check-cc)
(print "linking " target "...") (print "linking " target "...")
(if is-win (if is-win
(shell ld ;lflags (string "/OUT:" target) ;objects (win-import-library)) (shell linker ;lflags (string "/OUT:" target) ;objects (win-import-library))
(shell ld ;cflags `-o` target ;objects ;lflags)))) (shell linker ;cflags `-o` target ;objects ;lflags))))
(defn- archive-c (defn- archive-c
"Link object files together to make a static library." "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. --headerpath : The directory containing janet headers. Defaults to $JANET_HEADERPATH.
--binpath : The directory to install binaries and scripts. Defaults to $JANET_BINPATH. --binpath : The directory to install binaries and scripts. Defaults to $JANET_BINPATH.
--libpath : The directory containing janet C libraries (libjanet.*). Defaults to $JANET_LIBPATH. --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). --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 (lib 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 cc (link 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 --pkglist : URL of git repository for package listing. Defaults to $JANET_PKGLIST or https://github.com/janet-lang/pkgs.git
Flags are: Flags are:

11
jpm.1
View File

@@ -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. $JANET_LIBPATH, or a reasonable default. See JANET_LIBPATH for more.
.TP .TP
.BR \-\-compiler=cc .BR \-\-compiler=$CC
Sets the compiler used for compiling native modules and standalone executables. Defaults Sets the compiler used for compiling native modules and standalone executables. Defaults
to cc. to cc.
.TP .TP
.BR \-\-linker=ld .BR \-\-linker
Sets the linker used to create native modules and executables. Sets the linker used to create native modules and executables. Only used on windows, where
it defaults to link.exe.
.TP .TP
.BR \-\-pkglist=https://github.com/janet-lang/pkgs.git .BR \-\-pkglist=https://github.com/janet-lang/pkgs.git
Sets the git repository for the package listing used to resolve shorthand package names. Sets the git repository for the package listing used to resolve shorthand package names.
.TP .TP
.BR \-\-archiver=ar .BR \-\-archiver=$AR
Sets the command used for creating static libraries, use for linking into the standalone executable. 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 Native modules are compiled twice, once a normal native module (shared object), and once as an
archive. archive. Defaults to ar.
.SH COMMANDS .SH COMMANDS
.TP .TP