File tree 12 files changed +68
-26
lines changed
product-mini/platforms/linux
12 files changed +68
-26
lines changed Original file line number Diff line number Diff line change @@ -107,8 +107,6 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
107
107
108
108
include (${WAMR_ROOT_DIR} /build -scripts/runtime_lib.cmake)
109
109
110
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE" )
111
-
112
110
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow" )
113
111
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
114
112
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.9)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
project (iwasm)
7
9
@@ -119,7 +121,7 @@ set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
119
121
include (${WAMR_ROOT_DIR} /build -scripts/runtime_lib.cmake)
120
122
add_library (vmlib ${WAMR_RUNTIME_LIB_SOURCE} )
121
123
122
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE " )
124
+ set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
123
125
124
126
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow" )
125
127
# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
@@ -164,6 +166,9 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
164
166
165
167
add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE} )
166
168
169
+ check_pie_supported()
170
+ set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON )
171
+
167
172
install (TARGETS iwasm DESTINATION bin)
168
173
169
174
target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread)
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.9)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows" )
7
9
project (basic)
@@ -56,7 +58,6 @@ endif ()
56
58
57
59
if (NOT MSVC )
58
60
# linker flags
59
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
60
61
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
61
62
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
62
63
endif ()
@@ -80,6 +81,9 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
80
81
81
82
add_executable (basic src/main.c src/native_impl.c ${UNCOMMON_SHARED_SOURCE} )
82
83
84
+ check_pie_supported()
85
+ set_target_properties (basic PROPERTIES POSITION_INDEPENDENT_CODE ON )
86
+
83
87
if (APPLE )
84
88
target_link_libraries (basic vmlib -lm -ldl -lpthread)
85
89
else ()
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2022 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 3.0)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows" )
7
9
project (iwasm)
@@ -56,7 +58,6 @@ endif ()
56
58
57
59
if (NOT MSVC )
58
60
# linker flags
59
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
60
61
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
61
62
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
62
63
endif ()
@@ -80,6 +81,9 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
80
81
81
82
add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE} )
82
83
84
+ check_pie_supported()
85
+ set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON )
86
+
83
87
if (APPLE )
84
88
target_link_libraries (iwasm vmlib -lm -ldl -lpthread)
85
89
else ()
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.8...3.16)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
7
+
5
8
project (multi_module)
6
9
7
10
################ runtime settings ################
@@ -47,7 +50,6 @@ set(WAMR_BUILD_LIBC_WASI 1)
47
50
set (WAMR_BUILD_MULTI_MODULE 1)
48
51
49
52
# compiling and linking flags
50
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
51
53
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
52
54
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
53
55
endif ()
@@ -150,5 +152,8 @@ add_executable(multi_module src/main.c ${UNCOMMON_SHARED_SOURCE})
150
152
151
153
add_dependencies (multi_module vmlib WASM_MODULE)
152
154
155
+ check_pie_supported()
156
+ set_target_properties (multi_module PROPERTIES POSITION_INDEPENDENT_CODE ON )
157
+
153
158
# libraries
154
159
target_link_libraries (multi_module PRIVATE vmlib -lpthread -lm)
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.8)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
7
+
5
8
project (pthread)
6
9
7
10
################ runtime settings ################
@@ -48,7 +51,6 @@ set(WAMR_BUILD_LIB_PTHREAD 1)
48
51
set (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 1)
49
52
50
53
# compiling and linking flags
51
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
52
54
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
53
55
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
54
56
endif ()
@@ -73,5 +75,7 @@ set (RUNTIME_SOURCE_ALL
73
75
${UNCOMMON_SHARED_SOURCE}
74
76
)
75
77
add_executable (iwasm ${RUNTIME_SOURCE_ALL} )
78
+ check_pie_supported()
79
+ set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON )
76
80
target_link_libraries (iwasm vmlib -lpthread -lm -ldl)
77
81
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 3.0)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
7
+
5
8
project (native_lib)
6
9
7
10
################ runtime settings ##############
@@ -46,7 +49,6 @@ set (WAMR_BUILD_LIBC_BUILTIN 1)
46
49
set (WAMR_BUILD_FAST_INTERP 1)
47
50
48
51
# compiling and linking flags
49
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
50
52
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
51
53
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
52
54
endif ()
@@ -68,6 +70,9 @@ set (RUNTIME_SOURCE_ALL
68
70
69
71
add_executable (iwasm ${RUNTIME_SOURCE_ALL} )
70
72
73
+ check_pie_supported()
74
+ set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON )
75
+
71
76
target_link_libraries (iwasm vmlib -lpthread -lm -ldl)
72
77
73
78
################ native libraries ###############
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.9)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows" )
7
9
project (ref-types)
@@ -70,7 +72,6 @@ set(WAMR_BUILD_REF_TYPES 1)
70
72
71
73
if (NOT MSVC )
72
74
# compiling and linking flags
73
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
74
75
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
75
76
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
76
77
endif ()
@@ -107,6 +108,9 @@ include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
107
108
108
109
add_executable (hello src/hello.c ${UNCOMMON_SHARED_SOURCE} )
109
110
111
+ check_pie_supported()
112
+ set_target_properties (hello PROPERTIES POSITION_INDEPENDENT_CODE ON )
113
+
110
114
target_include_directories (hello PRIVATE ${UNCOMMON_SHARED_DIR} )
111
115
112
116
target_link_libraries (hello vmlib -lpthread -lm)
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.8...3.18)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
7
+
5
8
project (socket_api_sample)
6
9
7
10
#######################################
@@ -170,7 +173,6 @@ set(WAMR_BUILD_LIBC_WASI 1)
170
173
set (WAMR_BUILD_LIB_PTHREAD 1)
171
174
172
175
# compiling and linking flags
173
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
174
176
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
175
177
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
176
178
endif ()
@@ -188,4 +190,6 @@ set (RUNTIME_SOURCE_ALL
188
190
${UNCOMMON_SHARED_SOURCE}
189
191
)
190
192
add_executable (iwasm ${RUNTIME_SOURCE_ALL} )
193
+ check_pie_supported()
194
+ set_target_properties (iwasm PROPERTIES POSITION_INDEPENDENT_CODE ON )
191
195
target_link_libraries (iwasm vmlib -lpthread -lm -ldl)
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.8)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
7
+
5
8
project (spawn_thread)
6
9
7
10
################ runtime settings ################
@@ -47,7 +50,6 @@ set(WAMR_BUILD_FAST_INTERP 1)
47
50
set (WAMR_BUILD_LIB_PTHREAD 1)
48
51
49
52
# compiling and linking flags
50
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
51
53
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
52
54
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
53
55
endif ()
@@ -72,4 +74,6 @@ set (RUNTIME_SOURCE_ALL
72
74
${UNCOMMON_SHARED_SOURCE}
73
75
)
74
76
add_executable (spawn_thread ${RUNTIME_SOURCE_ALL} )
77
+ check_pie_supported()
78
+ set_target_properties (spawn_thread PROPERTIES POSITION_INDEPENDENT_CODE ON )
75
79
target_link_libraries (spawn_thread vmlib -lpthread -lm)
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.9)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows" )
7
9
project (c-api)
@@ -71,7 +73,6 @@ endif()
71
73
72
74
if (NOT MSVC )
73
75
# compiling and linking flags
74
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE" )
75
76
if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" ))
76
77
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections" )
77
78
endif ()
@@ -142,10 +143,13 @@ if(WAMR_BUILD_JIT AND WAMR_BUILD_LAZY_JIT)
142
143
endif ()
143
144
endif ()
144
145
146
+ check_pie_supported()
147
+
145
148
foreach (EX ${EXAMPLES} )
146
149
set (SRC ${CMAKE_CURRENT_LIST_DIR} /src/${EX} .c)
147
150
148
151
add_executable (${EX} ${SRC} ${UNCOMMON_SHARED_SOURCE} ${MM_UTIL} )
152
+ set_target_properties (${EX} PROPERTIES POSITION_INDEPENDENT_CODE ON )
149
153
target_include_directories (${EX} PRIVATE ${UNCOMMON_SHARED_DIR} )
150
154
target_link_libraries (${EX} vmlib -lpthread -lm)
151
155
if (MSVC )
Original file line number Diff line number Diff line change 1
1
# Copyright (C) 2019 Intel Corporation. All rights reserved.
2
2
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3
3
4
- cmake_minimum_required (VERSION 2.9)
4
+ cmake_minimum_required (VERSION 3.14)
5
+
6
+ include (CheckPIESupported)
5
7
6
8
if (NOT DEFINED WAMR_BUILD_PLATFORM)
7
9
if (CMAKE_SYSTEM_NAME )
@@ -237,9 +239,6 @@ endif()
237
239
if (NOT MSVC )
238
240
add_definitions (-D_FORTIFY_SOURCE=2)
239
241
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftrapv" )
240
- if (NOT WIN32 )
241
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pie -fPIE" )
242
- endif ()
243
242
endif ()
244
243
245
244
if (WIN32 )
@@ -264,6 +263,8 @@ add_library (vmlib
264
263
add_library (aotclib ${IWASM_COMPL_SOURCE} )
265
264
266
265
add_executable (wamrc main.c)
266
+ check_pie_supported()
267
+ set_target_properties (wamrc PROPERTIES POSITION_INDEPENDENT_CODE ON )
267
268
268
269
if (LLVM_LINK_LLVM_DYLIB)
269
270
set (WAMRC_LINK_LLVM_LIBS LLVM)
You can’t perform that action at this time.
0 commit comments