forked from hercules-390/SoftFloat-3a
-
Notifications
You must be signed in to change notification settings - Fork 5
/
cflags.txt
153 lines (126 loc) · 5.82 KB
/
cflags.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#------------------------------------------------------------------------------
# Adjust needed compile flags for this project/package
#------------------------------------------------------------------------------
include( CheckCCompilerFlag ) # Check compiler support for certain flags
include( targetver.txt ) # Define minimum required Windows platform
#------------------------------------------------------------------------------
# Little-endian / Big-endian
#------------------------------------------------------------------------------
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D LITTLE_ENDIAN=1234" )
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D BIG_ENDIAN=4321" )
if( IS_BIG_ENDIAN )
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D BYTE_ORDER=BIG_ENDIAN" )
else()
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D BYTE_ORDER=LITTLE_ENDIAN" )
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D LITTLEENDIAN" )
endif()
#------------------------------------------------------------------------------
# Add SoftFloat flags
#------------------------------------------------------------------------------
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D HAVE_PLATFORM_H" )
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D SOFTFLOAT_FAST_INT64" )
set( PKG_C_FLAGS "${PKG_C_FLAGS} -D SOFTFLOAT_FAST_DIV64TO32" )
#------------------------------------------------------------------------------
# PROGRAMMING NOTE
#------------------------------------------------------------------------------
# Due to SoftFloat's buggy support for function inlining we unfortunately
# cannot utilize it. The "primitives.h" header appears to be missing some
# #defines for some functions intending to be inlined thereby causing the
# function to be compiled twice: First as a primitives.h inlined function
# and then again as a normal non-inlined function within one of its source
# files.
#
# As an example, take the "softfloat_sub128" function: it's defined in the
# "primitives.h" header as a possibly inlined function as follows:
#
#
# #ifndef softfloat_sub128
# /*----------------------------------------------------------------------------
# | Returns the difference of the 128-bit integer formed by concatenating `a64'
# | and `a0' and the 128-bit integer formed by concatenating `b64' and `b0'.
# | The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
# *----------------------------------------------------------------------------*/
# #if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
# INLINE
# struct uint128
# softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
# {
# struct uint128 z;
# z.v0 = a0 - b0;
# z.v64 = a64 - b64;
# z.v64 -= (a0 < b0);
# return z;
# }
# #else
# struct uint128
# softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
# #endif
# #endif
#
#
# Thus, if INLINE_LEVEL is defined to a value greater than 2, it gets defined
# as an INLINE function within "primitives.h" header. Unfortunately however,
# the same function gets defined (compiled) as a normal non-inlined function
# in source file "s_sub128.c" as follows:
#
#
# #ifndef softfloat_sub128
# struct uint128
# softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
# {
# struct uint128 z;
#
# z.v0 = a0 - b0;
# z.v64 = a64 - b64 - (a0 < b0);
# return z;
#
# }
# #endif
#
#
# Since the "primitives.h" header is missing a #define for "softfloat_sub128"
# for "#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)" case, it causes the
# function to be generated (compiled) TWICE, leading to duplicate definition
# linker warnings when the library gets created:
#
# s_sub128.c.obj : warning LNK4006: softfloat_sub128 already defined in s_subMagsF128.c.obj; second definition ignored
# s_sub128.c.obj : warning LNK4221: no public symbols found; archive member will be inaccessible
#
#------------------------------------------------------------------------------
##set( PKG_C_FLAGS "${PKG_C_FLAGS} -D \"INLINE=static __inline\"" )
##set( PKG_C_FLAGS "${PKG_C_FLAGS} -D INLINE_LEVEL=5" )
#------------------------------------------------------------------------------
# Add above package flags
#------------------------------------------------------------------------------
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${PKG_C_FLAGS}" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${PKG_C_FLAGS}" )
#------------------------------------------------------------------------------
# Add other needed flags
#------------------------------------------------------------------------------
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D DEBUG" )
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D VERS_STRING=${VERS_STRING}" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D VERS_STRING=${VERS_STRING}" )
#------------------------------------------------------------------------------
# Some compilers don't accept either of the '-m32' or '-m64' machine options
# when support only exists for building 32-bit binaries but not 64-bit (i.e.
# if 64-bit support hasn't been installed then neither flag is accepted).
#------------------------------------------------------------------------------
if( NOT WIN32 )
set( TEMP_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}" )
set( CMAKE_REQUIRED_FLAGS "-m32" )
Check_C_Compiler_Flag( -m32 OK )
if( OK )
set( m32 "-m32" )
else()
set( m32 "" )
endif()
set( CMAKE_REQUIRED_FLAGS "-m64" )
Check_C_Compiler_Flag( -m64 OK )
set( CMAKE_REQUIRED_FLAGS "${TEMP_CMAKE_REQUIRED_FLAGS}" )
if( OK )
set( m64 "-m64" )
else()
set( m64 "" )
endif()
endif()
#------------------------------------------------------------------------------