Conflicting options in LuaJIT2 build script

  • From: Oliver Schneider <lua@xxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 21 Nov 2013 05:18:08 +0000

Hi Mike, everyone,

in msvcbuild.bat there is an issue when opting to build the static lib.

Basically at the top the "set LJCOMPILE" contains /MD which makes
assumptions of what the consuming executable is going to do during the
link step. I.e. it ties anyone trying to link against lua51.lib to the
multi-threaded runtime DLLs (msvcrt.dll and msvcrtd.dll and their
counterparts for the various VS versions).

So this has to go out.
That change doesn't affect the build of the minilua in any way, btw.

Then, a bit downward the %LJCOMPILE% invocations under :NODEBUG and
:AMALGDLL should mention the /MD again to not break anything for
existing users.

However, two more changes are required back at the top:

  @set LJLIB=lib /nologo /nodefaultlib

so that the created static lib does not include references to the
default libraries (no matter which ones!).

And then inside the :STATIC label lose the /DLUA_BUILD_AS_DLL on the
%LJCOMPILE% line. Perhaps that should be parametrized, though?

To sum it up:

<https://bitbucket.org/windirstat/windirstat/commits/5c50f977cf1dd7deac65f82c076d24e845c0d15e>

This way no assumptions are made about the way the projects consuming
LuaJIT link their stuff. Or am I missing anything, perhaps?

Thanks,

// Oliver

PS: I'll happily volunteer to fix up the script, if you let me. I've
written much more complex ones in the past (such as ddkbuild.cmd).
PPS: the actual patch:
diff -r f48718e9d9ce lua/src/msvcbuild.bat
--- a/lua/src/msvcbuild.bat     Thu Nov 21 05:14:07 2013 +0000
+++ b/lua/src/msvcbuild.bat     Thu Nov 21 05:14:39 2013 +0000
@@ -14,10 +14,10 @@
 @if not defined INCLUDE goto :FAIL

 @setlocal
-@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
 @set LJLINK=link /nologo
 @set LJMT=mt /nologo
-@set LJLIB=lib /nologo
+@set LJLIB=lib /nologo /nodefaultib
 @set DASMDIR=..\dynasm
 @set DASM=%DASMDIR%\dynasm.lua
 @set LJDLLNAME=lua51.dll
@@ -70,19 +70,19 @@
 :NODEBUG
 @if "%1"=="amalg" goto :AMALGDLL
 @if "%1"=="static" goto :STATIC
-%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
 @if errorlevel 1 goto :BAD
 %LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
 @if errorlevel 1 goto :BAD
 @goto :MTDLL
 :STATIC
-%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% lj_*.c lib_*.c
 @if errorlevel 1 goto :BAD
 %LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
 @if errorlevel 1 goto :BAD
 @goto :MTDLL
 :AMALGDLL
-%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
 @if errorlevel 1 goto :BAD
 %LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
 @if errorlevel 1 goto :BAD

Attachment: signature.asc
Description: OpenPGP digital signature

Other related posts: