8000 Misc. fixes for builtins lib on Windows · ldc-developers/compiler-rt@da0c0d3 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Commit da0c0d3

Browse files
committed
Misc. fixes for builtins lib on Windows
* Include ASM files when using MSVC-compatible clang-cl.exe as C compiler (and its assembler supporting AT&T syntax). * Disable buffer overflow checks to prevent dependencies on special MS C symbols. => /GS- * Use `/Zl` to prevent dragging in libcmt.lib. * Mark all i386 ASM files as SafeSEH-compatible on Win32.
1 parent 5bc7979 commit da0c0d3

18 files changed

+59
-3
lines changed

lib/builtins/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ set(x86_ARCH_SOURCES
230230
powixf2.c
231231
)
232232

233-
if (NOT MSVC)
233+
if (NOT CMAKE_ASM_COMPILER_ID MATCHES "MSVC")
234234
set(x86_64_SOURCES
235235
x86_64/floatdidf.c
236236
x86_64/floatdisf.c
@@ -271,7 +271,7 @@ if (NOT MSVC)
271271
i386/chkstk.S
272272
i386/chkstk2.S)
273273
endif()
274-
else () # MSVC
274+
else () # MSVC assembler
275275
# Use C versions of functions when building on MSVC
276276
# MSVC's assembler takes Intel syntax, not AT&T syntax.
277277
# Also use only MSVC compilable builtin implementations.
@@ -282,12 +282,17 @@ else () # MSVC
282282
${GENERIC_SOURCES})
283283
set(x86_64h_SOURCES ${x86_64_SOURCES})
284284
set(i386_SOURCES ${GENERIC_SOURCES})
285-
endif () # if (NOT MSVC)
285+
endif ()
286286

287287
set(x86_64h_SOURCES ${x86_64h_SOURCES} ${x86_ARCH_SOURCES})
288288
set(x86_64_SOURCES ${x86_64_SOURCES} ${x86_ARCH_SOURCES})
289289
set(i386_SOURCES ${i386_SOURCES} ${x86_ARCH_SOURCES})
290290
set(i686_SOURCES ${i686_SOURCES} ${x86_ARCH_SOURCES})
291+
if (MSVC)
292+
set_source_files_properties(
293+
${x86_64h_SOURCES} ${x86_64_SOURCES} ${i386_SOURCES} ${i686_SOURCES}
294+
PROPERTIES COMPILE_FLAGS "/GS- /Zl")
295+
endif()
291296

292297
set(arm_SOURCES
293298
arm/bswapdi2.S

lib/builtins/i386/ashldi3.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// di_int __ashldi3(di_int input, int count);
78

@@ -16,6 +17,7 @@
1617
#ifdef __SSE2__
1718

1819
.text
6DB6 20+
WIN32_SAFE_SEH_HEADER
1921
.balign 4
2022
DEFINE_COMPILERRT_FUNCTION(__ashldi3)
2123
movd 12(%esp), %xmm2 // Load count
@@ -36,6 +38,7 @@ END_COMPILERRT_FUNCTION(__ashldi3)
3638
#else // Use GPRs instead of SSE2 instructions, if they aren't available.
3739

3840
.text
41+
WIN32_SAFE_SEH_HEADER
3942
.balign 4
4043
DEFINE_COMPILERRT_FUNCTION(__ashldi3)
4144
movl 12(%esp), %ecx // Load count

lib/builtins/i386/ashrdi3.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// di_int __ashrdi3(di_int input, int count);
78

89
#ifdef __i386__
910
#ifdef __SSE2__
1011

1112
.text
13+
WIN32_SAFE_SEH_HEADER
1214
.balign 4
1315
DEFINE_COMPILERRT_FUNCTION(__ashrdi3)
1416
movd 12(%esp), %xmm2 // Load count
@@ -46,6 +48,7 @@ END_COMPILERRT_FUNCTION(__ashrdi3)
4648
#else // Use GPRs instead of SSE2 instructions, if they aren't available.
4749

4850
.text
51+
WIN32_SAFE_SEH_HEADER
4952
.balign 4
5053
DEFINE_COMPILERRT_FUNCTION(__ashrdi3)
5154
movl 12(%esp), %ecx // Load count

lib/builtins/i386/chkstk.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../ass F438 embly.h"
5+
#include "safeseh.h"
56

67
// _chkstk routine
78
// This routine is windows specific
@@ -10,6 +11,7 @@
1011
#ifdef __i386__
1112

1213
.text
14+
WIN32_SAFE_SEH_HEADER
1315
.balign 4
1416
DEFINE_COMPILERRT_FUNCTION(__chkstk_ms)
1517
push %ecx

lib/builtins/i386/chkstk2.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
#ifdef __i386__
78

@@ -11,6 +12,7 @@
1112
// http://msdn.microsoft.com/en-us/library/ms648426.aspx
1213

1314
.text
15+
WIN32_SAFE_SEH_HEADER
1416
.balign 4
1517
DEFINE_COMPILERRT_FUNCTION(_alloca) // _chkstk and _alloca are the same function
1618
DEFINE_COMPILERRT_FUNCTION(__chkstk)

lib/builtins/i386/divdi3.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// di_int __divdi3(di_int a, di_int b);
78

@@ -19,6 +20,7 @@
1920
#ifdef __i386__
2021

2122
.text
23+
WIN32_SAFE_SEH_HEADER
2224
.balign 4
2325
DEFINE_COMPILERRT_FUNCTION(__divdi3)
2426

lib/builtins/i386/floatdidf.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// double __floatundidf(du_int a);
78

@@ -20,6 +21,7 @@ twop32:
2021
#define REL_ADDR(_a) (_a)-0b(%eax)
2122

2223
.text
24+
WIN32_SAFE_SEH_HEADER
2325
.balign 4
2426
DEFINE_COMPILERRT_FUNCTION(__floatdidf)
2527
cvtsi2sd 8(%esp), %xmm1

lib/builtins/i386/floatdisf.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// float __floatdisf(di_int a);
78

@@ -15,6 +16,7 @@
1516
#ifdef __i386__
1617

1718
.text
19+
WIN32_SAFE_SEH_HEADER
1820
.balign 4
1921
DEFINE_COMPILERRT_FUNCTION(__floatdisf)
2022
#ifndef TRUST_CALLERS_USE_64_BIT_STORES

lib/builtins/i386/floatdixf.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Source Licenses. See LICENSE.TXT for details.
33

44
#include "../assembly.h"
5+
#include "safeseh.h"
56

67
// float __floatdixf(di_int a);
78

@@ -15,6 +16,7 @@
1516
// It can be turned off by defining the TRUST_CALLERS_USE_64_BIT_STORES macro.
1617

1718
.text
19+
WIN32_SAFE_SEH_HEADER
1820
.balign 4
1921
DEFINE_COMPILERRT_FUNCTION(__floatdixf)
2022
#ifndef TRUST_CALLERS_USE_64_BIT_STORES

lib/builtins/i386/floatundidf.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
#include "../assembly.h"
15+
#include "safeseh.h"
1516

1617
// double __floatundidf(du_int a);
1718

@@ -34,6 +35,7 @@ twop84:
3435
#define REL_ADDR(_a) (_a)-0b(%eax)
3536

3637
.text
38+
WIN32_SAFE_SEH_HEADER
3739
.balign 4
3840
DEFINE_COMPILERRT_FUNCTION(__floatundidf)
3941
movss 8(%esp), %xmm1 // high 32 bits of a

0 commit comments

Comments
 (0)
0