11# SPDX-License-Identifier: Apache-2.0
22# ----------------------------------------------------------------------------
3- # Copyright 2020-2022 Arm Limited
3+ # Copyright 2020-2023 Arm Limited
44#
55# Licensed under the Apache License, Version 2.0 (the "License"); you may not
66# use this file except in compliance with the License. You may obtain a copy
@@ -46,7 +46,6 @@ add_library(${ASTC_TARGET}-static
4646 astcenc_partition_tables.cpp
4747 astcenc_percentile_tables.cpp
4848 astcenc_pick_best_endpoint_format.cpp
49- astcenc_platform_isa_detection.cpp
5049 astcenc_quantization.cpp
5150 astcenc_symbolic_physical.cpp
5251 astcenc_weight_align.cpp
@@ -58,6 +57,11 @@ target_include_directories(${ASTC_TARGET}-static
5857 $<INSTALL_INTERFACE :.>)
5958
6059if (${CLI} )
60+ # Veneer is compiled without any extended ISA so we can safely do
61+ # ISA compatability checks without triggering a SIGILL
62+ add_library (${ASTC_TARGET} -veneer
63+ astcenccli_entry.cpp )
64+
6165 add_executable (${ASTC_TARGET}
6266 astcenccli_error_metrics.cpp
6367 astcenccli_image.cpp
@@ -69,10 +73,11 @@ if(${CLI})
6973
7074 target_link_libraries (${ASTC_TARGET}
7175 PRIVATE
76+ ${ASTC_TARGET} -veneer
7277 ${ASTC_TARGET} -static )
7378endif ()
7479
75- macro (astcenc_set_properties NAME )
80+ macro (astcenc_set_properties NAME IS_VENEER )
7681
7782 target_compile_features (${NAME}
7883 PRIVATE
@@ -223,8 +228,7 @@ macro(astcenc_set_properties NAME)
223228 ASTCENC_F16C=0 )
224229 endif ()
225230
226- # These settings are needed on AppleClang as SSE4.1 is on by default
227- # Suppress unused argument for macOS universal build behavior
231+ # Force SSE2 on AppleClang (normally SSE4.1 is the default)
228232 target_compile_options (${NAME}
229233 PRIVATE
230234 $<$<CXX_COMPILER_ID :AppleClang >:-msse2 >
@@ -242,11 +246,19 @@ macro(astcenc_set_properties NAME)
242246 ASTCENC_F16C=0 )
243247 endif ()
244248
245- # Suppress unused argument for macOS universal build behavior
246- target_compile_options (${NAME}
247- PRIVATE
248- $<$<NOT :$<CXX_COMPILER_ID :MSVC >>:-msse4 .1 -mpopcnt >
249- $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
249+ if (${IS_VENEER} )
250+ # Force SSE2 on AppleClang (normally SSE4.1 is the default)
251+ target_compile_options (${NAME}
252+ PRIVATE
253+ $<$<CXX_COMPILER_ID :AppleClang >:-msse2 >
254+ $<$<CXX_COMPILER_ID :AppleClang >:-mno -sse4 .1>
255+ $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
256+ else ()
257+ target_compile_options (${NAME}
258+ PRIVATE
259+ $<$<NOT :$<CXX_COMPILER_ID :MSVC >>:-msse4 .1 -mpopcnt >
260+ $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
261+ endif ()
250262
251263 elseif ((${ISA_SIMD} MATCHES "avx2" ) OR (${UNIVERSAL_BUILD} AND ${ISA_AVX2} ))
252264 if (NOT ${UNIVERSAL_BUILD} )
@@ -259,20 +271,28 @@ macro(astcenc_set_properties NAME)
259271 ASTCENC_F16C=1 )
260272 endif ()
261273
262- # Suppress unused argument for macOS universal build behavior
263- target_compile_options (${NAME}
264- PRIVATE
265- $<$<NOT :$<CXX_COMPILER_ID :MSVC >>:-mavx2 -mpopcnt -mf16c >
266- $<$<CXX_COMPILER_ID :MSVC >:/arch :AVX2 >
267- $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
274+ if (${IS_VENEER} )
275+ # Force SSE2 on AppleClang (normally SSE4.1 is the default)
276+ target_compile_options (${NAME}
277+ PRIVATE
278+ $<$<CXX_COMPILER_ID :AppleClang >:-msse2 >
279+ $<$<CXX_COMPILER_ID :AppleClang >:-mno -sse4 .1>
280+ $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
281+ else ()
282+ target_compile_options (${NAME}
283+ PRIVATE
284+ $<$<NOT :$<CXX_COMPILER_ID :MSVC >>:-mavx2 -mpopcnt -mf16c >
285+ $<$<CXX_COMPILER_ID :MSVC >:/arch :AVX2 >
286+ $<$<CXX_COMPILER_ID :AppleClang >:-Wno -unused -command -line -argument >)
287+ endif ()
268288
269289 # Non-invariant builds enable us to loosen the compiler constraints on
270290 # floating point, but this is only worth doing on CPUs with AVX2 because
271291 # this implies we can also enable the FMA instruction set extensions
272292 # which significantly improve performance. Note that this DOES reduce
273293 # image quality by up to 0.2 dB (normally much less), but buys an
274294 # average of 10-15% performance improvement ...
275- if (${NO_INVARIANCE} )
295+ if (${NO_INVARIANCE} AND NOT ${IS_VENEER} )
276296 target_compile_options (${NAME}
277297 PRIVATE
278298 $<$<NOT :$<CXX_COMPILER_ID :MSVC >>:-mfma >)
@@ -309,19 +329,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
309329 COMPILE_FLAGS ${EXTERNAL_CXX_FLAGS} )
310330endif ()
311331
312- astcenc_set_properties (${ASTC_TARGET} -static )
332+ astcenc_set_properties (${ASTC_TARGET} -static OFF )
313333
314334 target_compile_options (${ASTC_TARGET} -static
315335 PRIVATE
316336 $<$<CXX_COMPILER_ID :MSVC >:/W4 >)
317337
318338if (${CLI} )
319- astcenc_set_properties (${ASTC_TARGET} )
339+ astcenc_set_properties (${ASTC_TARGET} -veneer ON )
340+ astcenc_set_properties (${ASTC_TARGET} OFF )
320341
321342 target_compile_options (${ASTC_TARGET}
322343 PRIVATE
323344 $<$<CXX_COMPILER_ID :MSVC >:/W3 >)
324345
346+ target_compile_options (${ASTC_TARGET} -veneer
347+ PRIVATE
348+ $<$<CXX_COMPILER_ID :MSVC >:/W3 >)
349+
325350 string (TIMESTAMP astcencoder_YEAR "%Y" )
326351
327352 configure_file (
0 commit comments