Bläddra i källkod

Fixed Win32 32-bit link issue on recent 64-bit MinGW.
Linux build additions. Support for musl libc and static linking.

woollybah 9 år sedan
förälder
incheckning
d348a2e9b5
5 ändrade filer med 54 tillägg och 3 borttagningar
  1. 2 0
      bmk.bmx
  2. 37 1
      bmk_config.bmx
  3. 6 0
      bmk_make.bmx
  4. 8 1
      bmk_util.bmx
  5. 1 1
      make.bmk

+ 2 - 0
bmk.bmx

@@ -1,5 +1,7 @@
 '
 '
 ' Change History :
 ' Change History :
+' 3.15 16/07/2016 - Linux build additions. Support for musl libc and static linking.
+'                   Fixed Win32 32-bit link issue on recent 64-bit MinGW.
 ' 3.14 05/06/2016 - Can now set command-line options via custom.bmk.
 ' 3.14 05/06/2016 - Can now set command-line options via custom.bmk.
 ' 3.13 21/05/2016 - Added default simd cc_opt for x64 (-msse4).
 ' 3.13 21/05/2016 - Added default simd cc_opt for x64 (-msse4).
 ' 3.12 17/04/2016 - App link optimisations.
 ' 3.12 17/04/2016 - App link optimisations.

+ 37 - 1
bmk_config.bmx

@@ -6,7 +6,7 @@ Import BRL.StandardIO
 ?macos
 ?macos
 Import Pub.MacOS
 Import Pub.MacOS
 ?
 ?
-Const BMK_VERSION:String = "3.14"
+Const BMK_VERSION:String = "3.15"
 
 
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc"
 Const ALL_SRC_EXTS$="bmx;i;c;m;h;cpp;cxx;mm;hpp;hxx;s;cc"
 
 
@@ -46,6 +46,10 @@ Global opt_nostrictupgrade=False
 Global opt_nostrictupgrade_set=False
 Global opt_nostrictupgrade_set=False
 Global opt_warnover=False
 Global opt_warnover=False
 Global opt_warnover_set=False
 Global opt_warnover_set=False
+Global opt_musl=False
+Global opt_musl_set=False
+Global opt_static=False
+Global opt_static_set=False
 
 
 Global opt_dumpbuild
 Global opt_dumpbuild
 
 
@@ -213,6 +217,12 @@ Function ParseConfigArgs$[]( args$[] )
 		Case "w"
 		Case "w"
 			opt_warnover = True
 			opt_warnover = True
 			opt_warnover_set = True
 			opt_warnover_set = True
+		Case "musl"
+			opt_musl = True
+			opt_musl_set = True
+		Case "static"
+			opt_static = True
+			opt_static_set = True
 		Default
 		Default
 			CmdError "Invalid option '" + arg[1..] + "'"
 			CmdError "Invalid option '" + arg[1..] + "'"
 		End Select
 		End Select
@@ -328,6 +338,9 @@ Function Usage:String(fullUsage:Int = False)
 		s:+ "~t~tValid targets are win32, linux, macos, ios, android, raspberrypi and emscripten.~n"
 		s:+ "~t~tValid targets are win32, linux, macos, ios, android, raspberrypi and emscripten.~n"
 		s:+ "~t~t(see documentation for full list of requirements)"
 		s:+ "~t~t(see documentation for full list of requirements)"
 		s:+ "~n~n"
 		s:+ "~n~n"
+		s:+ "~t-musl~n"
+		s:+ "~t~tEnable musl libc compatibility. (Linux NG only)"
+		s:+ "~n~n"
 		s:+ "~t-nostrictupgrade~n"
 		s:+ "~t-nostrictupgrade~n"
 		s:+ "~t~tDon't upgrade strict method void return types, if required. (NG only)~n"
 		s:+ "~t~tDon't upgrade strict method void return types, if required. (NG only)~n"
 		s:+ "~t~tIf a Strict sub type overrides the method of a SuperStrict type and the return type is void,~n"
 		s:+ "~t~tIf a Strict sub type overrides the method of a SuperStrict type and the return type is void,~n"
@@ -353,6 +366,9 @@ Function Usage:String(fullUsage:Int = False)
 		s:+ "~t~tGenerate but do not compile into binary form.~n"
 		s:+ "~t~tGenerate but do not compile into binary form.~n"
 		s:+ "~t~tUseful for creating ready-to-build source for a different platform/architecture."
 		s:+ "~t~tUseful for creating ready-to-build source for a different platform/architecture."
 		s:+ "~n~n"
 		s:+ "~n~n"
+		s:+ "~t-static~n"
+		s:+ "~t~tStatically link binary. (Linux NG only)"
+		s:+ "~n~n"
 		s:+ "~t-t <app type>~n"
 		s:+ "~t-t <app type>~n"
 		s:+ "~t~tSpecify application type. (makeapp only)~n"
 		s:+ "~t~tSpecify application type. (makeapp only)~n"
 		s:+ "~t~tShould be either 'console' or 'gui' (without single quote!).~n"
 		s:+ "~t~tShould be either 'console' or 'gui' (without single quote!).~n"
@@ -499,6 +515,26 @@ Function AsConfigurable:Int(key:String, value:String)
 				End If
 				End If
 			End If
 			End If
 			config = True
 			config = True
+		Case "opt_musl"
+			If Not opt_musl_set Then
+				opt_musl = Int(value)
+				set = 1
+			Else
+				If opt_musl <> Int(value) Then
+					set = 2
+				End If
+			End If
+			config = True
+		Case "opt_static"
+			If Not opt_static_set Then
+				opt_static = Int(value)
+				set = 1
+			Else
+				If opt_static <> Int(value) Then
+					set = 2
+				End If
+			End If
+			config = True
 	End Select
 	End Select
 	If set And opt_verbose Then
 	If set And opt_verbose Then
 		If set = 1 Then
 		If set = 1 Then

+ 6 - 0
bmk_make.bmx

@@ -309,6 +309,9 @@ Type TBuildManager
 			If opt_warnover Then
 			If opt_warnover Then
 				bcc_opts:+" -w"
 				bcc_opts:+" -w"
 			End If
 			End If
+			If opt_musl Then
+				bcc_opts:+" -musl"
+			End If
 		End If
 		End If
 
 
 		source.cc_opts :+ cc_opts
 		source.cc_opts :+ cc_opts
@@ -1039,6 +1042,9 @@ Type TBuildManager
 				If opt_warnover Then
 				If opt_warnover Then
 					bcc_opts:+" -w"
 					bcc_opts:+" -w"
 				End If
 				End If
+				If opt_musl Then
+					bcc_opts:+" -musl"
+				End If
 			End If
 			End If
 	
 	
 			source.bcc_opts = bcc_opts
 			source.bcc_opts = bcc_opts

+ 8 - 1
bmk_util.bmx

@@ -274,7 +274,7 @@ Function LinkApp( path$,lnk_files:TList,makelib,opts$ )
 		cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )
 		cmd:+" "+CQuote( "-L"+CQuote( BlitzMaxPath()+"/lib" ) )
 	
 	
 		If Not opt_dumpbuild cmd:+" -filelist "+CQuote( tmpfile )
 		If Not opt_dumpbuild cmd:+" -filelist "+CQuote( tmpfile )
-		
+
 		For Local t$=EachIn lnk_files
 		For Local t$=EachIn lnk_files
 			If opt_dumpbuild Or (t[..1]="-")
 			If opt_dumpbuild Or (t[..1]="-")
 				cmd:+" "+t 
 				cmd:+" "+t 
@@ -416,6 +416,10 @@ Function LinkApp( path$,lnk_files:TList,makelib,opts$ )
 			' if using 4.8+ or mingw64, we need to link to pthreads
 			' if using 4.8+ or mingw64, we need to link to pthreads
 			If version >= 40800 Or processor.HasTarget("x86_64") Then
 			If version >= 40800 Or processor.HasTarget("x86_64") Then
 				files :+ " -lwinpthread "
 				files :+ " -lwinpthread "
+				
+				If processor.CPU()="x86" Then
+					files:+" -lgcc"
+				End If
 			End If
 			End If
 			
 			
 			files :+ " -lmoldname -lmsvcrt "
 			files :+ " -lmoldname -lmsvcrt "
@@ -453,6 +457,9 @@ Function LinkApp( path$,lnk_files:TList,makelib,opts$ )
 		If processor.CPU() = "x64" Or processor.CPU() = "arm64" Then
 		If processor.CPU() = "x64" Or processor.CPU() = "arm64" Then
 			cmd:+" -m64"
 			cmd:+" -m64"
 		End If
 		End If
+		If opt_static Then
+			cmd:+" -static"
+		End If
 		cmd:+" -pthread"
 		cmd:+" -pthread"
 		cmd:+" -o "+CQuote( path )
 		cmd:+" -o "+CQuote( path )
 		cmd:+" "+CQuote( tmpfile )
 		cmd:+" "+CQuote( tmpfile )

+ 1 - 1
make.bmk

@@ -417,7 +417,7 @@
 
 
 	globals.SetOption("cc_opts", "exceptions", "-fno-exceptions")
 	globals.SetOption("cc_opts", "exceptions", "-fno-exceptions")
 	globals.SetOption("cc_opts", "linker", "-c")
 	globals.SetOption("cc_opts", "linker", "-c")
-	globals.SetOption("cc_opts", "optimization", "-O2")
+	globals.SetOption("cc_opts", "optimization", "-O3")
 	if bmk.CPU() == "x64" then
 	if bmk.CPU() == "x64" then
 		globals.SetOption("cc_opts", "simd", "-msse4")
 		globals.SetOption("cc_opts", "simd", "-msse4")
 	end
 	end