Browse Source

bldy: compile with platform and CC specific options

Signed-off-by: Sevki <s@sevki.org>
Sevki 7 years ago
parent
commit
29a6cb1dbb
3 changed files with 35 additions and 61 deletions
  1. 28 26
      sys/src/9/amd64/BUILD
  2. 6 2
      sys/src/FLAGS
  3. 1 33
      sys/src/harvey.BUILD

+ 28 - 26
sys/src/9/amd64/BUILD

@@ -235,7 +235,7 @@ objcopy(
 	outfile="elf32-i386",
 )
 
-HRVYDEPS =[
+HRVYDEPS = [
 	":amd64cpu",
 	":error",
 	":errstr",
@@ -243,34 +243,36 @@ HRVYDEPS =[
 	":sys",
 	":inith",
 ]
+STD_COMPILER_OPTIONS = [
+	"-mcmodel=kernel",
+	"-O0",
+	"-static",
+	"-mno-red-zone",
+	"-ffreestanding",
+	"-fno-builtin",
+	"-DKERNDATE=1433623937",
+	"-g",
+	"-Wall",
+	"-Werror",
+	"-W",
+	"-Wno-sign-compare",
+	"-Wno-missing-field-initializers",
+	"-Wno-unused-parameter",
+	"-Wno-unused-function",
+	"-Wno-missing-braces",
+	"-Wno-parentheses",
+	"-Wno-unknown-pragmas",
+	"-D__HARVEY__",
+	"-U_LINUX",
+	"-U__linux__",
+	"-fasm",
+]
+
+load("//sys/src/9/amd64/${CC}.BUILD", "COMPILER_FLAGS")
 
 cc_binary(
 	name="harvey",
-	copts=[
-		# "-c", this is always on
-		"-std=c11",
-		"-mcmodel=kernel",
-		"-O0",
-		"-static",
-		"-mno-red-zone",
-		"-ffreestanding",
-		"-fno-builtin",
-		"-DKERNDATE=1433623937",
-		"-g",
-		"-Wall",
-		"-W",
-		"-Wno-unused-function",
-		"-Wno-sign-compare",
-		"-Wno-missing-field-initializers",
-		"-Wno-unused-parameter",
-		"-Wno-missing-braces",
-		"-Wno-parentheses",
-		"-Wno-unknown-pragmas",
-		"-D__HARVEY__",
-		"-U_LINUX",
-		"-U__linux__",
-		"-fasm",
-	],
+	copts=STD_COMPILER_OPTIONS + COMPILER_FLAGS,
 	srcs=AMD64SRCS,
 	includes=[
 		"//sys/include",

+ 6 - 2
sys/src/FLAGS

@@ -1,3 +1,5 @@
+load("//${ARCH}/${CC}.BUILD", "COMPILER_FLAGS")
+
 CMD_DEPS = [
 	"//sys/src/libavl:libavl",
 	"//sys/src/libcomplete:libcomplete",
@@ -97,7 +99,7 @@ CMD_LINK_OPTS = [
 
 ]
 
-KLIB_COMPILER_FLAGS = [
+STD_KLIB_COMPILER_FLAGS = [
 	"-mcmodel=kernel",
 	"-O0",
 	"-mno-red-zone",
@@ -111,7 +113,7 @@ KLIB_COMPILER_FLAGS = [
 	"-g",
 ]
 
-LIB_COMPILER_FLAGS = [
+STD_LIB_COMPILER_FLAGS = [
 	"-std=c11",
 	"-fasm",
 	"-c",
@@ -128,3 +130,5 @@ LIB_COMPILER_FLAGS = [
 	"-Wno-parentheses",
 	"-Wno-unknown-pragmas"
 ]
+LIB_COMPILER_FLAGS = STD_LIB_COMPILER_FLAGS + COMPILER_FLAGS
+KLIB_COMPILER_FLAGS = STD_KLIB_COMPILER_FLAGS + COMPILER_FLAGS

+ 1 - 33
sys/src/harvey.BUILD

@@ -1,3 +1,4 @@
+load("//sys/src/FLAGS", "LIB_COMPILER_FLAGS")
 CMD_DEPS = [
 	"//sys/src/libavl:libavl",
 	"//sys/src/libcomplete:libcomplete",
@@ -37,39 +38,6 @@ CMD_LINK_OPTS = [
 	"-e_main",
 ]
 
-KLIB_COMPILER_FLAGS = [
-	"-mcmodel=kernel",
-	"-O0",
-	"-mno-red-zone",
-	"-ffreestanding",
-	"-fno-builtin",
-	"-Wall",
-	"-Wno-missing-braces",
-	"-Wno-parentheses",
-	"-Wno-unknown-pragmas",
-	"-Wuninitialized",
-	"-g",
-]
-
-LIB_COMPILER_FLAGS = [
-	"-std=c11",
-	"-fasm",
-	"-c",
-	"-ffreestanding",
-	"-fno-builtin",
-	"-fno-omit-frame-pointer",
-	"-g",
-	"-gdwarf-2",
-	"-ggdb",
-	"-mcmodel=small",
-	"-mno-red-zone",
-	"-O0",
-	"-static",
-	"-Wall",
-	"-Wno-missing-braces",
-	"-Wno-parentheses",
-	"-Wno-unknown-pragmas"
-]
 
 harvey_binary = cc_binary(
 	copts=LIB_COMPILER_FLAGS,