diff --git a/Rsconscript b/Rsconscript index 7388861..eefc7db 100644 --- a/Rsconscript +++ b/Rsconscript @@ -69,6 +69,18 @@ class Image < Builder end end +class CheckThreadLocal < Builder + def run(options) + map_file = File.binread(@sources.first) + if map_file =~ /\.(tdata|tbss)\b/ + $stderr.puts "Error: found thread-local data in #{@sources.first}" + false + else + true + end + end +end + class FontGen < Builder def run(options) if @command @@ -88,6 +100,7 @@ end hulk_env = env "hulk", use: %w[ldc2 x86_64-elf-gcc] do |env| env.add_builder(FontGen) + env.add_builder(CheckThreadLocal) env.FontGen("^/src/hulk/kfont.d", "font/Hack-Regular.ttf", "fontgen" => fontgen_env.expand("^/fontgen")) env["sources"] = glob("src/hulk/**/*.d") @@ -102,6 +115,7 @@ hulk_env = env "hulk", use: %w[ldc2 x86_64-elf-gcc] do |env| env["OBJCOPY"] = "x86_64-elf-objcopy" env.Program("^/hulk.elf", "${sources}") env.produces("^/hulk.elf", "^/hulk.elf.map") + env.CheckThreadLocal(:hulk_map_check, "^/hulk.elf.map") env.depends("^/hulk.elf", "src/hulk/hulk.ld") env["SIZE"] = "x86_64-elf-size" env.Size("^/hulk.size", "^/hulk.elf") @@ -118,6 +132,7 @@ end hello_env = env "hello", use: %w[ldc2 x86_64-w64-mingw32-gcc] do |env| env.add_builder(Image) + env.add_builder(CheckThreadLocal) env.add_builder(HulkBinObj) env["sources"] = glob("src/hello/**/*.d") env["sources"] += glob("uefi-d/source/**/*.d") @@ -133,6 +148,7 @@ hello_env = env "hello", use: %w[ldc2 x86_64-w64-mingw32-gcc] do |env| env["OBJDUMP"] = "x86_64-w64-mingw32-objdump" env.Program("^/HOS.EFI", "${sources}") env.produces("^/HOS.EFI", "^/HOS.EFI.map") + env.CheckThreadLocal(:hos_map_check, "^/HOS.EFI.map") env["SIZE"] = "x86_64-w64-mingw32-size" env.Size("^/HOS.size", "^/HOS.EFI") env.Disassemble("^/HOS.txt", "^/HOS.EFI")