summary refs log tree commit diff
path: root/pkgs/development/compilers/terra/nix-cflags.patch
blob: 90ba7e63f1d0d74adbc4ea53f051f20da330dbd8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/terralib.lua b/src/terralib.lua
index 532ed18..2c265dc 100644
--- a/src/terralib.lua
+++ b/src/terralib.lua
@@ -3426,6 +3426,16 @@ function terra.includecstring(code,cargs,target)
     	args:insert("-internal-isystem")
     	args:insert(path)
     end
+    -- NOTE(aseipp): include relevant Nix header files
+    args:insert("-isystem")
+    args:insert("@NIX_LIBC_INCLUDE@")
+
+    local nix_cflags = os.getenv('NIX_CFLAGS_COMPILE')
+    if nix_cflags ~= nil then
+        for w in nix_cflags:gmatch("%S+") do
+          args:insert(w)
+        end
+    end
     -- Obey the SDKROOT variable on macOS to match Clang behavior.
     local sdkroot = os.getenv("SDKROOT")
     if sdkroot then