Skip to content

Commit 978a0cd

Browse files
committed
Makefile: fix LLVM tools detection for wasi-libc
This makes the `make wasi-libc` command much more reliable and makes the CI configuration simpler. Also, it avoids warnings when they are not relevant.
1 parent 6896b00 commit 978a0cd

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ commands:
5353
steps:
5454
- restore_cache:
5555
keys:
56-
- wasi-libc-sysroot-v0
56+
- wasi-libc-sysroot-v1
5757
- run:
5858
name: "Build wasi-libc"
59-
command: make wasi-libc CLANG=$PWD/llvm-build/bin/clang LLVM_AR=$PWD/llvm-build/bin/llvm-ar LLVM_NM=$PWD/llvm-build/bin/llvm-nm
59+
command: make wasi-libc
6060
- save_cache:
61-
key: wasi-libc-sysroot-v0
61+
key: wasi-libc-sysroot-v1
6262
paths:
6363
- lib/wasi-libc/sysroot
6464
test-linux:
@@ -266,12 +266,12 @@ commands:
266266
llvm-build
267267
- restore_cache:
268268
keys:
269-
- wasi-libc-sysroot-macos-v0
269+
- wasi-libc-sysroot-macos-v1
270270
- run:
271271
name: "Build wasi-libc"
272-
command: make wasi-libc CLANG=$PWD/llvm-build/bin/clang LLVM_AR=$PWD/llvm-build/bin/llvm-ar LLVM_NM=$PWD/llvm-build/bin/llvm-nm
272+
command: make wasi-libc
273273
- save_cache:
274-
key: wasi-libc-sysroot-macos-v0
274+
key: wasi-libc-sysroot-macos-v1
275275
paths:
276276
- lib/wasi-libc/sysroot
277277
- run:

Makefile

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,26 @@ LLVM_BUILDDIR ?= llvm-build
77
CLANG_SRC ?= llvm-project/clang
88
LLD_SRC ?= llvm-project/lld
99

10-
# Default tool selection.
11-
CLANG ?= clang-9
12-
13-
# Try to autodetect llvm-ar and llvm-nm
14-
ifneq (, $(shell command -v llvm-ar-9 2> /dev/null))
10+
# Try to autodetect LLVM build tools.
11+
ifneq (, $(shell command -v llvm-build/bin/clang 2> /dev/null))
12+
CLANG ?= $(abspath llvm-build/bin/clang)
13+
else
14+
CLANG ?= clang-9
15+
endif
16+
ifneq (, $(shell command -v llvm-build/bin/llvm-ar 2> /dev/null))
17+
LLVM_AR ?= $(abspath llvm-build/bin/llvm-ar)
18+
else ifneq (, $(shell command -v llvm-ar-9 2> /dev/null))
1519
LLVM_AR ?= llvm-ar-9
16-
else ifneq (, $(shell command -v llvm-ar 2> /dev/null))
20+
else
1721
LLVM_AR ?= llvm-ar
1822
endif
19-
ifneq (, $(shell command -v llvm-nm-9 2> /dev/null))
23+
ifneq (, $(shell command -v llvm-build/bin/llvm-nm 2> /dev/null))
24+
LLVM_NM ?= $(abspath llvm-build/bin/llvm-nm)
25+
else ifneq (, $(shell command -v llvm-nm-9 2> /dev/null))
2026
LLVM_NM ?= llvm-nm-9
21-
else ifneq (, $(shell command -v llvm-nm 2> /dev/null))
27+
else
2228
LLVM_NM ?= llvm-nm
2329
endif
24-
ifndef LLVM_AR
25-
$(warning llvm-ar not found)
26-
endif
27-
ifndef LLVM_NM
28-
$(warning llvm-nm not found)
29-
endif
3030

3131
# Go binary and GOROOT to select
3232
GO ?= go

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ jobs:
4848
- task: CacheBeta@0
4949
displayName: Cache wasi-libc sysroot
5050
inputs:
51-
key: wasi-libc-sysroot-v0
51+
key: wasi-libc-sysroot-v1
5252
path: lib/wasi-libc/sysroot
5353
- task: Bash@3
5454
displayName: Build wasi-libc
5555
inputs:
5656
targetType: inline
57-
script: PATH=/usr/bin:$PATH make wasi-libc CLANG=$PWD/llvm-build/bin/clang LLVM_AR=$PWD/llvm-build/bin/llvm-ar LLVM_NM=$PWD/llvm-build/bin/llvm-nm
57+
script: PATH=/usr/bin:$PATH make wasi-libc
5858
- task: Bash@3
5959
displayName: Test TinyGo
6060
inputs:

0 commit comments

Comments
 (0)