Skip to content

Commit 255e6f7

Browse files
Add Azure Pipelines definition (#78)
1 parent d4db3fa commit 255e6f7

2 files changed

Lines changed: 72 additions & 11 deletions

File tree

.azure-pipelines.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
trigger:
2+
- master
3+
4+
jobs:
5+
- job: Build
6+
timeoutInMinutes: 360
7+
strategy:
8+
matrix:
9+
windows:
10+
imageName: 'vs2017-win2016'
11+
mac:
12+
imageName: 'macos-10.14'
13+
linux:
14+
imageName: 'ubuntu-16.04'
15+
16+
pool:
17+
vmImage: $(imageName)
18+
19+
steps:
20+
- script: |
21+
powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %TEMP%\LLVM-8.0.0-win64.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-8.0.0-win64.exe"
22+
set CLANG_DIR=%CD%\citools\clang-rust
23+
start "" /WAIT %TEMP%\LLVM-8.0.0-win64.exe /S /NCRC /D=%CLANG_DIR%
24+
echo ##vso[task.prependpath]%CLANG_DIR%/bin
25+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
26+
displayName: Install clang (Windows)
27+
- bash: |
28+
set -euo pipefail
29+
curl -f http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz | tar xJf -
30+
export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/bin
31+
echo "##vso[task.prependpath]$CLANG_DIR"
32+
displayName: Install clang (OSX)
33+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
34+
- bash: |
35+
set -euo pipefail
36+
curl -f http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf -
37+
export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin
38+
echo "##vso[task.prependpath]$CLANG_DIR"
39+
displayName: Install clang (Linux)
40+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
41+
- bash: |
42+
# Windows releases of LLVM don't include the llvm-nm tool, which is needed for building
43+
# wasi-libc. Rust's llvm-tools include llvm-nm, and Rust is installed on Azure's Windows
44+
# images, so we can use that to make llvm-nm available without too much overhead.
45+
set -euo pipefail
46+
rustup update stable
47+
rustup default stable
48+
rustup component add llvm-tools-preview
49+
echo "##vso[task.setvariable variable=WASM_NM;]$(rustc --print sysroot|sed 's|C:|/c|'|sed 's|\\|/|g')/lib/rustlib/x86_64-pc-windows-msvc/bin/llvm-nm.exe"
50+
displayName: Install llvm-nm (Windows)
51+
condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' ))
52+
- script: make -j4
53+
displayName: Build

Makefile

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# These variables are specifically meant to be overridable via
22
# the make command-line.
3-
WASM_CC = clang
4-
WASM_NM = $(patsubst %clang,%llvm-nm,$(WASM_CC))
5-
WASM_AR = $(patsubst %clang,%llvm-ar,$(WASM_CC))
6-
WASM_CFLAGS = -O2
3+
WASM_CC ?= clang
4+
WASM_NM ?= $(patsubst %clang,%llvm-nm,$(WASM_CC))
5+
WASM_AR ?= $(patsubst %clang,%llvm-ar,$(WASM_CC))
6+
WASM_CFLAGS ?= -O2
77
# The directory where we build the sysroot.
8-
SYSROOT = $(CURDIR)/sysroot
8+
SYSROOT ?= $(CURDIR)/sysroot
99
# A directory to install to for "make install".
10-
INSTALL_DIR = /usr/local
10+
INSTALL_DIR ?= /usr/local
1111
# single or posix
1212
THREAD_MODEL = single
1313
# yes or no
@@ -245,7 +245,14 @@ $(SYSROOT_LIB)/libwasi-emulated-mman.a: $(LIBWASI_EMULATED_MMAN_OBJS)
245245

246246
%.a:
247247
@mkdir -p "$(@D)"
248-
$(WASM_AR) crs $@ $^
248+
# On Windows, the commandline for the ar invocation got too long, so it needs to be split up.
249+
$(WASM_AR) crs $@ $(wordlist 1, 199, $^)
250+
$(WASM_AR) crs $@ $(wordlist 200, 399, $^)
251+
$(WASM_AR) crs $@ $(wordlist 400, 599, $^)
252+
$(WASM_AR) crs $@ $(wordlist 600, 799, $^)
253+
# This might eventually overflow again, but at least it'll do so in a loud way instead of
254+
# silently dropping the tail.
255+
$(WASM_AR) crs $@ $(wordlist 800, 100000, $^)
249256

250257
$(MUSL_PRINTSCAN_OBJS): override WASM_CFLAGS += \
251258
-D__wasilibc_printscan_no_long_double \
@@ -267,7 +274,7 @@ $(OBJDIR)/%.o: $(CURDIR)/%.c include_dirs
267274
@mkdir -p "$(@D)"
268275
"$(WASM_CC)" $(WASM_CFLAGS) -MD -MP -o $@ -c $<
269276

270-
include $(shell find $(OBJDIR) -name \*.d) /dev/null
277+
-include $(shell find $(OBJDIR) -name \*.d)
271278

272279
$(DLMALLOC_OBJS): override WASM_CFLAGS += \
273280
-I$(DLMALLOC_INC)
@@ -444,9 +451,9 @@ finish: startup_files libc
444451
# Collect symbol information.
445452
# TODO: Use llvm-nm --extern-only instead of grep. This is blocked on
446453
# LLVM PR40497, which is fixed in 9.0, but not in 8.0.
447-
$(WASM_NM) --defined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/*.o \
454+
"$(WASM_NM)" --defined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/*.o \
448455
|grep ' [[:upper:]] ' |sed 's/.* [[:upper:]] //' |LC_ALL=C sort > "$(SYSROOT_SHARE)/defined-symbols.txt"
449-
for undef_sym in $$($(WASM_NM) --undefined-only "$(SYSROOT_LIB)"/*.a "$(SYSROOT_LIB)"/*.o \
456+
for undef_sym in $$("$(WASM_NM)" --undefined-only "$(SYSROOT_LIB)"/*.a "$(SYSROOT_LIB)"/*.o \
450457
|grep ' U ' |sed 's/.* U //' |LC_ALL=C sort |uniq); do \
451458
grep -q '\<'$$undef_sym'\>' "$(SYSROOT_SHARE)/defined-symbols.txt" || echo $$undef_sym; \
452459
done > "$(SYSROOT_SHARE)/undefined-symbols.txt"
@@ -499,7 +506,8 @@ finish: startup_files libc
499506

500507
check: finish
501508
# Check that the computed metadata matches the expected metadata.
502-
diff -ur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
509+
# This ignores whitespace because on Windows the output has CRLF line endings.
510+
diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
503511

504512
install: finish
505513
mkdir -p "$(INSTALL_DIR)"

0 commit comments

Comments
 (0)