From bfc3ce31576f837398c1077a31e3cb5213551ee2 Mon Sep 17 00:00:00 2001 From: DRC Date: Tue, 10 Apr 2018 15:50:22 -0500 Subject: [PATCH] x86[-64] SIMD: Don't auto-generate jsimdcfg.inc The old Un*x (autotools-based) build system always auto-generated this file, but that behavior was more or less a relic of the days before the libjpeg-turbo colorspace extensions were implemented. The thinking was that, if a particular developer wanted to change RGB_RED, RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE in order to compress from/decompress to different RGB pixel layouts, then the SIMD extensions should automatically respond to those changes whenever they were made to jmorecfg.h. The modern reality is that changing RGB_* is no longer necessary because of the libjpeg-turbo colorspace extensions, and changing any of the other constants in jsimdcfg.inc can't be done without making deeper modifications to the SIMD extensions. In general, we treat RGB_* as a de facto, immutable part of the legacy libpjeg API. Realistically, since the values of those constants have been the same in every Un*x distribution released in the past 20-30 years, any software that uses a system-supplied build of libjpeg must assume that those constants will have default values. Furthermore, even if it made sense to auto-generate jsimdcfg.inc, it was never possible to do so on Windows, so it was always going to be necessary to manually generate the Windows version of the file whenever any of the constants changed. This commit introduces a new custom CMake target called "jsimdcfg" that can be used, on Un*x platforms, to generate jsimdcfg.inc on demand, although this should only be necessary when introducing new x86 SIMD instructions or making other deep modifications, such as SIMD acceleration for 12-bit JPEGs. For those who may be wondering why we don't do the same thing for win/jconfig.h.in, it's because performing all of the necessary CMake checks to populate that file is very slow on Windows. --- simd/CMakeLists.txt | 23 ++++++++++------------- {win => simd/nasm}/jsimdcfg.inc | 0 simd/{ => nasm}/jsimdcfg.inc.h | 0 3 files changed, 10 insertions(+), 13 deletions(-) rename {win => simd/nasm}/jsimdcfg.inc (100%) mode change 100755 => 100644 rename simd/{ => nasm}/jsimdcfg.inc.h (100%) diff --git a/simd/CMakeLists.txt b/simd/CMakeLists.txt index 2b37525..2468b1b 100755 --- a/simd/CMakeLists.txt +++ b/simd/CMakeLists.txt @@ -91,19 +91,16 @@ message(STATUS "CMAKE_ASM_NASM_FLAGS = ${EFFECTIVE_ASM_NASM_FLAGS}") set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I\"${CMAKE_CURRENT_SOURCE_DIR}/nasm/\" -I\"${CMAKE_CURRENT_SOURCE_DIR}/${CPU_TYPE}/\"") -if(WIN32) - set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I\"${CMAKE_CURRENT_SOURCE_DIR}/../win/\"") - set(JSIMDCFG_INC ${CMAKE_CURRENT_SOURCE_DIR}/../win/jsimdcfg.inc) -else() - set(GREP grep) - if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") - set(GREP ggrep) - endif() - add_custom_command(OUTPUT jsimdcfg.inc - COMMAND ${CMAKE_C_COMPILER} -E -I${CMAKE_BINARY_DIR} -I${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/jsimdcfg.inc.h | ${GREP} -E '^[\;%]|^\ %' | sed 's%_cpp_protection_%%' | sed 's@% define@%define@g' >jsimdcfg.inc) - set(JSIMDCFG_INC ${CMAKE_CURRENT_BINARY_DIR}/jsimdcfg.inc) - set(CMAKE_ASM_NASM_FLAGS "${CMAKE_ASM_NASM_FLAGS} -I\"${CMAKE_CURRENT_BINARY_DIR}/\"") +set(GREP grep) +if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(GREP ggrep) endif() +add_custom_target(jsimdcfg COMMAND + ${CMAKE_C_COMPILER} -E -I${CMAKE_BINARY_DIR} -I${CMAKE_CURRENT_BINARY_DIR} + -I${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/nasm/jsimdcfg.inc.h | + ${GREP} -E '^[\;%]|^\ %' | sed 's%_cpp_protection_%%' | + sed 's@% define@%define@g' >${CMAKE_CURRENT_SOURCE_DIR}/nasm/jsimdcfg.inc) if(CPU_TYPE STREQUAL "x86_64") set(SIMD_SOURCES x86_64/jsimdcpu.asm x86_64/jfdctflt-sse.asm @@ -164,7 +161,7 @@ foreach(file ${SIMD_SOURCES}) set(OBJECT_DEPENDS ${OBJECT_DEPENDS} ${CMAKE_CURRENT_SOURCE_DIR}/${DEPFILE}) endif() - set(OBJECT_DEPENDS ${OBJECT_DEPENDS} ${INC_FILES} ${JSIMDCFG_INC}) + set(OBJECT_DEPENDS ${OBJECT_DEPENDS} ${INC_FILES}) if(MSVC_IDE) # The CMake Visual Studio generators do not work properly with the ASM_NASM # language, so we have to go rogue here and use a custom command like we diff --git a/win/jsimdcfg.inc b/simd/nasm/jsimdcfg.inc old mode 100755 new mode 100644 similarity index 100% rename from win/jsimdcfg.inc rename to simd/nasm/jsimdcfg.inc diff --git a/simd/jsimdcfg.inc.h b/simd/nasm/jsimdcfg.inc.h similarity index 100% rename from simd/jsimdcfg.inc.h rename to simd/nasm/jsimdcfg.inc.h -- 2.40.0