diff options
author | Nia Waldvogel <[email protected]> | 2022-01-08 09:19:32 -0500 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-01-09 18:46:15 +0100 |
commit | cb01d4d63e09b894969a22a4621c693f55353fd0 (patch) | |
tree | a623856b4fb482e5d508ee313e7d90e7dabd22a1 | |
parent | fe21650010aa824a224f6a17b2a7eaa0f56e52a6 (diff) | |
download | tinygo-cb01d4d63e09b894969a22a4621c693f55353fd0.tar.gz tinygo-cb01d4d63e09b894969a22a4621c693f55353fd0.zip |
builder (env): update clang header search path to look in /usr/lib
Arch Linux stores the clang executable seperately from its data, so the search based on the executable does not work.
This change searches /usr/lib as a backup.
-rw-r--r-- | builder/env.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/builder/env.go b/builder/env.go index 5fec0d826..b28173c44 100644 --- a/builder/env.go +++ b/builder/env.go @@ -84,6 +84,20 @@ func getClangHeaderPath(TINYGOROOT string) string { } } + // On Arch Linux, the clang executable is stored in /usr/bin rather than being symlinked from there. + // Search directly in /usr/lib for clang. + if matches, err := filepath.Glob("/usr/lib/clang/" + llvmMajor + ".*.*"); err == nil { + // Check for the highest version first. + sort.Strings(matches) + for i := len(matches) - 1; i >= 0; i-- { + path := filepath.Join(matches[i], "include") + _, err := os.Stat(filepath.Join(path, "stdint.h")) + if err == nil { + return path + } + } + } + // Could not find it. return "" } |