Skip to content

Commit cc403b6

Browse files
committed
Auto merge of #29478 - angelsl:msvc2, r=alexcrichton
r? @alexcrichton
2 parents a216e84 + 9fe4e96 commit cc403b6

File tree

6 files changed

+90
-35
lines changed

6 files changed

+90
-35
lines changed

configure

+27-19
Original file line numberDiff line numberDiff line change
@@ -1484,25 +1484,9 @@ do
14841484
done
14851485
fi
14861486

1487-
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -ne 0 ]
1487+
# We need the generator later on for compiler-rt even if LLVM's not built
1488+
if [ ${is_msvc} -ne 0 ]
14881489
then
1489-
msg "configuring LLVM for $t with cmake"
1490-
1491-
CMAKE_ARGS="-DLLVM_INCLUDE_TESTS=OFF"
1492-
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
1493-
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
1494-
else
1495-
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
1496-
fi
1497-
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
1498-
then
1499-
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=OFF"
1500-
else
1501-
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
1502-
fi
1503-
1504-
msg "configuring LLVM with:"
1505-
msg "$CMAKE_ARGS"
15061490
case "$CFG_MSVC_ROOT" in
15071491
*14.0*)
15081492
generator="Visual Studio 14 2015"
@@ -1524,8 +1508,32 @@ do
15241508
err "can only build LLVM for x86 platforms"
15251509
;;
15261510
esac
1511+
CFG_CMAKE_GENERATOR=$generator
1512+
putvar CFG_CMAKE_GENERATOR
1513+
fi
1514+
1515+
if [ ${do_reconfigure} -ne 0 ] && [ ${is_msvc} -ne 0 ]
1516+
then
1517+
msg "configuring LLVM for $t with cmake"
1518+
1519+
CMAKE_ARGS="-DLLVM_INCLUDE_TESTS=OFF"
1520+
if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then
1521+
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
1522+
else
1523+
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
1524+
fi
1525+
if [ -z "$CFG_ENABLE_LLVM_ASSERTIONS" ]
1526+
then
1527+
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=OFF"
1528+
else
1529+
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
1530+
fi
1531+
1532+
msg "configuring LLVM with:"
1533+
msg "$CMAKE_ARGS"
1534+
15271535
(cd $LLVM_BUILD_DIR && "$CFG_CMAKE" $CFG_LLVM_SRC_DIR \
1528-
-G "$generator" \
1536+
-G "$CFG_CMAKE_GENERATOR" \
15291537
$CMAKE_ARGS)
15301538
need_ok "LLVM cmake configure failed"
15311539
fi

mk/rt.mk

+24-15
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,31 @@ COMPRT_NAME_$(1) := $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
216216
COMPRT_LIB_$(1) := $$(RT_OUTPUT_DIR_$(1))/$$(COMPRT_NAME_$(1))
217217
COMPRT_BUILD_DIR_$(1) := $$(RT_OUTPUT_DIR_$(1))/compiler-rt
218218

219-
# Note that on MSVC-targeting builds we hardwire CC/AR to gcc/ar even though
220-
# we're targeting MSVC. This is because although compiler-rt has a CMake build
221-
# config I can't actually figure out how to use it, so I'm not sure how to use
222-
# cl.exe to build the objects. Additionally, the compiler-rt library when built
223-
# with gcc has the same ABI as cl.exe, so they're largely compatible
224-
COMPRT_CC_$(1) := $$(CC_$(1))
225-
COMPRT_AR_$(1) := $$(AR_$(1))
226-
COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1))
227219
ifeq ($$(findstring msvc,$(1)),msvc)
228-
COMPRT_CC_$(1) := gcc
229-
COMPRT_AR_$(1) := ar
230-
ifeq ($$(findstring i686,$(1)),i686)
231-
COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1)) -m32
220+
$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS) $$(LLVM_CONFIG_$(1))
221+
@$$(call E, cmake: compiler-rt)
222+
$$(Q)cd "$$(COMPRT_BUILD_DIR_$(1))"; $$(CFG_CMAKE) "$(S)src/compiler-rt" \
223+
-DCMAKE_BUILD_TYPE=$$(LLVM_BUILD_CONFIG_MODE) \
224+
-DLLVM_CONFIG_PATH=$$(LLVM_CONFIG_$(1)) \
225+
-G"$$(CFG_CMAKE_GENERATOR)"
226+
$$(Q)$$(CFG_CMAKE) --build "$$(COMPRT_BUILD_DIR_$(1))" \
227+
--target lib/builtins/builtins \
228+
--config $$(LLVM_BUILD_CONFIG_MODE) \
229+
-- //v:m //nologo
230+
$$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/lib/windows/$$(LLVM_BUILD_CONFIG_MODE)/clang_rt.builtins-$$(HOST_$(1)).lib $$@
232231
else
233-
COMPRT_CFLAGS_$(1) := $$(CFG_GCCISH_CFLAGS_$(1)) -m64
234-
endif
232+
COMPRT_CC_$(1) := $$(CC_$(1))
233+
COMPRT_AR_$(1) := $$(AR_$(1))
234+
# We chomp -Werror here because GCC warns about the type signature of
235+
# builtins not matching its own and the build fails. It's a bit hacky,
236+
# but what can we do, we're building libclang-rt using GCC ......
237+
COMPRT_CFLAGS_$(1) := $$(subst -Werror,,$$(CFG_GCCISH_CFLAGS_$(1))) -std=c99
238+
239+
# FreeBSD Clang's packaging is problematic; it doesn't copy unwind.h to
240+
# the standard include directory. This should really be in our changes to
241+
# compiler-rt, but we override the CFLAGS here so there isn't much choice
242+
ifeq ($$(findstring freebsd,$(1)),freebsd)
243+
COMPRT_CFLAGS_$(1) += -I/usr/include/c++/v1
235244
endif
236245

237246
$$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS)
@@ -246,7 +255,7 @@ $$(COMPRT_LIB_$(1)): $$(COMPRT_DEPS) $$(MKFILE_DEPS)
246255
TargetTriple=$(1) \
247256
triple-builtins
248257
$$(Q)cp $$(COMPRT_BUILD_DIR_$(1))/triple/builtins/libcompiler_rt.a $$@
249-
258+
endif
250259
################################################################################
251260
# libbacktrace
252261
#

src/compiler-rt

Submodule compiler-rt updated 1585 files
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-include ../tools.mk
2+
3+
ifneq (,$(findstring MINGW,$(UNAME)))
4+
ifndef IS_MSVC
5+
all:
6+
g++ foo.cpp -c -o $(TMPDIR)/foo.o
7+
ar crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
8+
$(RUSTC) foo.rs -lfoo -lstdc++
9+
$(call RUN,foo)
10+
else
11+
all:
12+
13+
endif
14+
else
15+
all:
16+
17+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ignore-license
2+
extern "C" void foo() {
3+
int *a = new int(3);
4+
delete a;
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern { fn foo(); }
12+
13+
pub fn main() {
14+
unsafe { foo(); }
15+
assert_eq!(7f32.powi(3), 343f32);
16+
}

0 commit comments

Comments
 (0)