Skip to content

Commit 86d9cc9

Browse files
committed
Trying to fix Windows build...
1 parent faf7a11 commit 86d9cc9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,5 @@ workflows:
223223
test-all:
224224
jobs:
225225
- test-llvm11-go115
226-
- test-llvm12-go116
227-
- build-macos
226+
#- test-llvm12-go116
227+
#- build-macos

Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,13 @@ ifeq ($(OS),Windows_NT)
5959

6060
BINARYEN_OPTION += -DCMAKE_EXE_LINKER_FLAGS='-static-libgcc -static-libstdc++'
6161

62-
LIBCLANG_NAME = libclang
63-
6462
else ifeq ($(shell uname -s),Darwin)
6563
MD5SUM = md5
66-
LIBCLANG_NAME = clang
6764
else ifeq ($(shell uname -s),FreeBSD)
6865
MD5SUM = md5
69-
LIBCLANG_NAME = clang
7066
START_GROUP = -Wl,--start-group
7167
END_GROUP = -Wl,--end-group
7268
else
73-
LIBCLANG_NAME = clang
7469
START_GROUP = -Wl,--start-group
7570
END_GROUP = -Wl,--end-group
7671
endif
@@ -86,19 +81,22 @@ LLD_LIBS = $(START_GROUP) $(addprefix -l,$(LLD_LIB_NAMES)) $(END_GROUP)
8681
# Other libraries that are needed to link TinyGo.
8782
EXTRA_LIB_NAMES = LLVMInterpreter
8883

84+
# All libraries to be built and linked with the tinygo binary (lib/lib*.a).
85+
LIB_NAMES = clang $(CLANG_LIB_NAMES) $(LLD_LIB_NAMES) $(EXTRA_LIB_NAMES)
86+
8987
# These build targets appear to be the only ones necessary to build all TinyGo
9088
# dependencies. Only building a subset significantly speeds up rebuilding LLVM.
9189
# The Makefile rules convert a name like lldELF to lib/liblldELF.a to match the
9290
# library path (for ninja).
9391
# This list also includes a few tools that are necessary as part of the full
9492
# TinyGo build.
95-
NINJA_BUILD_TARGETS = clang llvm-config llvm-ar llvm-nm $(addprefix lib/lib,$(addsuffix .a,$(LIBCLANG_NAME) $(CLANG_LIB_NAMES) $(LLD_LIB_NAMES) $(EXTRA_LIB_NAMES)))
93+
NINJA_BUILD_TARGETS = clang llvm-config llvm-ar llvm-nm $(addprefix lib/lib,$(addsuffix .a,$(LIB_NAMES)))
9694

9795
# For static linking.
9896
ifneq ("$(wildcard $(LLVM_BUILDDIR)/bin/llvm-config*)","")
9997
CGO_CPPFLAGS+=$(shell $(LLVM_BUILDDIR)/bin/llvm-config --cppflags) -I$(abspath $(LLVM_BUILDDIR))/tools/clang/include -I$(abspath $(CLANG_SRC))/include -I$(abspath $(LLD_SRC))/include
10098
CGO_CXXFLAGS=-std=c++14
101-
CGO_LDFLAGS+=$(abspath $(LLVM_BUILDDIR))/lib/lib$(LIBCLANG_NAME).a -L$(abspath $(LLVM_BUILDDIR)/lib) $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
99+
CGO_LDFLAGS+=-L$(abspath $(LLVM_BUILDDIR)/lib) -lclang $(CLANG_LIBS) $(LLD_LIBS) $(shell $(LLVM_BUILDDIR)/bin/llvm-config --ldflags --libs --system-libs $(LLVM_COMPONENTS)) -lstdc++ $(CGO_LDFLAGS_EXTRA)
102100
endif
103101

104102

compileopts/target.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,19 @@ func defaultTarget(goos, goarch, triple string) (*TargetSpec, error) {
279279
} else if goos == "windows" {
280280
spec.Linker = "ld.lld"
281281
spec.Libc = "mingw-w64"
282+
// Note: using a medium code model, low image base and no ASLR
283+
// because Go doesn't really need those features. ASLR patches
284+
// around issues for unsafe languages like C/C++ that are not
285+
// normally present in Go (without explicitly opting in).
286+
// For more discussion:
287+
// https://groups.google.com/g/Golang-nuts/c/Jd9tlNc6jUE/m/Zo-7zIP_m3MJ?pli=1
282288
spec.LDFlags = append(spec.LDFlags,
283289
"-m", "i386pep",
284290
"-Bdynamic",
285291
"--image-base", "0x400000",
286292
"--gc-sections",
287293
"--no-insert-timestamp",
294+
"--no-dynamicbase",
288295
)
289296
} else {
290297
spec.LDFlags = append(spec.LDFlags, "-no-pie", "-Wl,--gc-sections") // WARNING: clang < 5.0 requires -nopie

0 commit comments

Comments
 (0)