From ff57a29e0f1b5d13d8a006b270442882a9f308b1 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 24 Apr 2016 21:38:59 +0300 Subject: [PATCH] make separate option for using nasm asm Other asm is now enabled by default again, since asm blocks are now smarter and won't fail to compile on non-i386 platforms. --- Sources/CMakeLists.txt | 22 ++++++++++++++-------- Sources/Engine/Sound/SoundMixer.cpp | 8 ++++---- Sources/build-linux32.sh | 4 ++-- Sources/build-linux64.sh | 2 +- Sources/build-mac.sh | 2 +- Sources/build-mac64.sh | 2 +- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index c43ced8..39ab5f7 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -188,13 +188,20 @@ else() set(DEBUGSUFFIX "") endif() -# This should not be needed anymore, but might be faster on 32bit x86 -option(USE_I386_ASM "Use X86 ASM" FALSE) +option(USE_ASM "Use ASM code" TRUE) +if (USE_ASM) + MESSAGE(STATUS "Using assembler code (when available)") +else() + add_definitions(-DUSE_PORTABLE_C=1) + MESSAGE(STATUS "Using portable C instead of all ASM") +endif() -if (USE_I386_ASM) +option(USE_I386_NASM_ASM "Use i386 nasm ASM code" FALSE) + +if (USE_ASM AND USE_I386_NASM_ASM) # You need the Netwide Assembler (NASM) to build this on Intel systems. # http://nasm.sf.net/ - add_definitions(-DUSE_I386_ASM=1) + add_definitions(-DUSE_I386_NASM_ASM=1) if (MACOSX) set(ASMOBJFMT "macho") list(APPEND ASMFLAGS --prefix _) @@ -203,10 +210,9 @@ if (USE_I386_ASM) else() set(ASMOBJFMT "elf") endif() - MESSAGE(STATUS "Using i386 assembler") + MESSAGE(STATUS "Using i386 nasm ASM") else() - add_definitions(-DUSE_PORTABLE_C=1) - MESSAGE(STATUS "Using portable C instead of ASM") + MESSAGE(STATUS "Not using i386 nasm ASM") endif() option(PANDORA "Compile for Pandora" FALSE) @@ -655,7 +661,7 @@ add_dependencies(${SHADERSLIB} ParseEntities) add_parser_and_scanner("Engine/Base/Parser" "Engine/Base/Scanner") add_parser_and_scanner("Engine/Ska/smcPars" "Engine/Ska/smcScan") -if (USE_I386_ASM) +if (USE_I386_NASM_ASM) add_custom_command( OUTPUT "SoundMixer386.o" MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/Engine/Sound/SoundMixer386.asm" diff --git a/Sources/Engine/Sound/SoundMixer.cpp b/Sources/Engine/Sound/SoundMixer.cpp index adc16a0..df07861 100644 --- a/Sources/Engine/Sound/SoundMixer.cpp +++ b/Sources/Engine/Sound/SoundMixer.cpp @@ -43,7 +43,7 @@ static CSoundData *psd; // nasm on MacOS X is getting wrong addresses of external globals, so I have // to define them in the .asm file...lame. -#if (defined __GNU_INLINE_X86_32__) +#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) #define INASM extern #elif (defined __MSVC_INLINE__) #define INASM static @@ -283,7 +283,7 @@ void NormalizeMixerBuffer( const FLOAT fNormStrength, const SLONG slBytes, FLOAT } -#ifdef __GNU_INLINE_X86_32__ +#if (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // These are implemented in an external NASM file. extern "C" { void MixStereo_asm(CSoundObject *pso); @@ -430,7 +430,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE_X86_32__) + #elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // This is implemented in an external NASM file. MixMono_asm(pso); @@ -658,7 +658,7 @@ loopEnd: emms } - #elif (defined __GNU_INLINE_X86_32__) + #elif (defined __GNU_INLINE_X86_32__) && (defined USE_I386_NASM_ASM) // This is implemented in an external NASM file. MixStereo_asm(pso); diff --git a/Sources/build-linux32.sh b/Sources/build-linux32.sh index 4f44315..f7bf3fa 100755 --- a/Sources/build-linux32.sh +++ b/Sources/build-linux32.sh @@ -14,10 +14,10 @@ cd $_ #ninja # This is the eventual path for amd64. -#cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. +#cmake -DCMAKE_BUILD_TYPE=Debug .. # Right now we force x86, though... -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_ASM=TRUE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -DUSE_I386_NASM_ASM=TRUE .. make -j$NCPU diff --git a/Sources/build-linux64.sh b/Sources/build-linux64.sh index d81e4dd..44fe793 100755 --- a/Sources/build-linux64.sh +++ b/Sources/build-linux64.sh @@ -14,7 +14,7 @@ cd $_ #ninja # This is the eventual path for amd64. -cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_I386_ASM=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug .. # Right now we force x86, though... #cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 .. diff --git a/Sources/build-mac.sh b/Sources/build-mac.sh index a0311cf..1f01255 100755 --- a/Sources/build-mac.sh +++ b/Sources/build-mac.sh @@ -9,6 +9,6 @@ set -x rm -rf cmake-build mkdir $_ cd $_ -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=i386 -DUSE_I386_NASM_ASM=TRUE -DUSE_SYSTEM_SDL2=FALSE .. make -j$NCPU diff --git a/Sources/build-mac64.sh b/Sources/build-mac64.sh index 52f295b..5265cdc 100755 --- a/Sources/build-mac64.sh +++ b/Sources/build-mac64.sh @@ -9,6 +9,6 @@ set -x rm -rf cmake-build mkdir $_ cd $_ -cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 -DUSE_I386_ASM=FALSE .. +cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_OSX_ARCHITECTURES=x86_64 .. make -j$NCPU