]> git.proxmox.com Git - wasi-libc.git/commitdiff
Add Azure Pipelines definition (#78)
authorTill Schneidereit <till@tillschneidereit.net>
Mon, 12 Aug 2019 11:50:53 +0000 (13:50 +0200)
committerGitHub <noreply@github.com>
Mon, 12 Aug 2019 11:50:53 +0000 (13:50 +0200)
.azure-pipelines.yml [new file with mode: 0644]
Makefile

diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
new file mode 100644 (file)
index 0000000..7e82e18
--- /dev/null
@@ -0,0 +1,53 @@
+trigger:
+  - master
+
+jobs:
+- job: Build
+  timeoutInMinutes: 360
+  strategy:
+    matrix:
+      windows:
+        imageName: 'vs2017-win2016'
+      mac:
+        imageName: 'macos-10.14'
+      linux:
+        imageName: 'ubuntu-16.04'
+
+  pool:
+    vmImage: $(imageName)
+
+  steps:
+    - script: |
+        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"
+        set CLANG_DIR=%CD%\citools\clang-rust
+        start "" /WAIT %TEMP%\LLVM-8.0.0-win64.exe /S /NCRC /D=%CLANG_DIR%
+        echo ##vso[task.prependpath]%CLANG_DIR%/bin
+      condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
+      displayName: Install clang (Windows)
+    - bash: |
+        set -euo pipefail
+        curl -f http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz | tar xJf -
+        export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/bin
+        echo "##vso[task.prependpath]$CLANG_DIR"
+      displayName: Install clang (OSX)
+      condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin'))
+    - bash: |
+        set -euo pipefail
+        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 -
+        export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin
+        echo "##vso[task.prependpath]$CLANG_DIR"
+      displayName: Install clang (Linux)
+      condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
+    - bash: |
+        # Windows releases of LLVM don't include the llvm-nm tool, which is needed for building
+        # wasi-libc. Rust's llvm-tools include llvm-nm, and Rust is installed on Azure's Windows
+        # images, so we can use that to make llvm-nm available without too much overhead.
+        set -euo pipefail
+        rustup update stable
+        rustup default stable
+        rustup component add llvm-tools-preview
+        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"
+      displayName: Install llvm-nm (Windows)
+      condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' ))
+    - script: make -j4
+      displayName: Build
index 843c385974488bf47d130d0a6b617e32ccc5da72..83c863229cc1a909a2380043fb2b9a96b79ec0e4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,13 @@
 # These variables are specifically meant to be overridable via
 # the make command-line.
-WASM_CC = clang
-WASM_NM = $(patsubst %clang,%llvm-nm,$(WASM_CC))
-WASM_AR = $(patsubst %clang,%llvm-ar,$(WASM_CC))
-WASM_CFLAGS = -O2
+WASM_CC ?= clang
+WASM_NM ?= $(patsubst %clang,%llvm-nm,$(WASM_CC))
+WASM_AR ?= $(patsubst %clang,%llvm-ar,$(WASM_CC))
+WASM_CFLAGS ?= -O2
 # The directory where we build the sysroot.
-SYSROOT = $(CURDIR)/sysroot
+SYSROOT ?= $(CURDIR)/sysroot
 # A directory to install to for "make install".
-INSTALL_DIR = /usr/local
+INSTALL_DIR ?= /usr/local
 # single or posix
 THREAD_MODEL = single
 # yes or no
@@ -245,7 +245,14 @@ $(SYSROOT_LIB)/libwasi-emulated-mman.a: $(LIBWASI_EMULATED_MMAN_OBJS)
 
 %.a:
        @mkdir -p "$(@D)"
-       $(WASM_AR) crs $@ $^
+       # On Windows, the commandline for the ar invocation got too long, so it needs to be split up.
+       $(WASM_AR) crs $@ $(wordlist 1, 199, $^)
+       $(WASM_AR) crs $@ $(wordlist 200, 399, $^)
+       $(WASM_AR) crs $@ $(wordlist 400, 599, $^)
+       $(WASM_AR) crs $@ $(wordlist 600, 799, $^)
+       # This might eventually overflow again, but at least it'll do so in a loud way instead of
+       # silently dropping the tail.
+       $(WASM_AR) crs $@ $(wordlist 800, 100000, $^)
 
 $(MUSL_PRINTSCAN_OBJS): override WASM_CFLAGS += \
            -D__wasilibc_printscan_no_long_double \
@@ -267,7 +274,7 @@ $(OBJDIR)/%.o: $(CURDIR)/%.c include_dirs
        @mkdir -p "$(@D)"
        "$(WASM_CC)" $(WASM_CFLAGS) -MD -MP -o $@ -c $<
 
-include $(shell find $(OBJDIR) -name \*.d) /dev/null
+-include $(shell find $(OBJDIR) -name \*.d)
 
 $(DLMALLOC_OBJS): override WASM_CFLAGS += \
     -I$(DLMALLOC_INC)
@@ -444,9 +451,9 @@ finish: startup_files libc
        # Collect symbol information.
        # TODO: Use llvm-nm --extern-only instead of grep. This is blocked on
        # LLVM PR40497, which is fixed in 9.0, but not in 8.0.
-       $(WASM_NM) --defined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/*.o \
+       "$(WASM_NM)" --defined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/*.o \
            |grep ' [[:upper:]] ' |sed 's/.* [[:upper:]] //' |LC_ALL=C sort > "$(SYSROOT_SHARE)/defined-symbols.txt"
-       for undef_sym in $$($(WASM_NM) --undefined-only "$(SYSROOT_LIB)"/*.a "$(SYSROOT_LIB)"/*.o \
+       for undef_sym in $$("$(WASM_NM)" --undefined-only "$(SYSROOT_LIB)"/*.a "$(SYSROOT_LIB)"/*.o \
            |grep ' U ' |sed 's/.* U //' |LC_ALL=C sort |uniq); do \
            grep -q '\<'$$undef_sym'\>' "$(SYSROOT_SHARE)/defined-symbols.txt" || echo $$undef_sym; \
        done > "$(SYSROOT_SHARE)/undefined-symbols.txt"
@@ -499,7 +506,8 @@ finish: startup_files libc
 
 check: finish
        # Check that the computed metadata matches the expected metadata.
-       diff -ur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
+       # This ignores whitespace because on Windows the output has CRLF line endings.
+       diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
 
 install: finish
        mkdir -p "$(INSTALL_DIR)"