From 8dce60814d65b774761cf016bdff86818cd6363a Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Sat, 5 Oct 2024 14:35:34 +0300 Subject: [PATCH 1/5] =?UTF-8?q?Sobirajem=20Kompil=C3=A4tor1=20pod=20boleje?= =?UTF-8?q?=20novyje=20pro=C3=A7essory=20x86,=20a=20ne=20pod=20to=20govno?= =?UTF-8?q?=20mamonta,=20pod=20kotoryj=20po=20umolcaniju=20sobirajet=20kod?= =?UTF-8?q?=20x86-bekend=20biblioteki=20"LLVM".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/compiler1/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/source/compiler1/CMakeLists.txt b/source/compiler1/CMakeLists.txt index ffcee5223..b9861a24f 100644 --- a/source/compiler1/CMakeLists.txt +++ b/source/compiler1/CMakeLists.txt @@ -15,6 +15,9 @@ else() set( SPRACHE_COMPILER_OPT_OPTIONS -O2 ) endif() +# Use a CPU from year 2015 or newer. It seems to be fine to avoid using older CPUs. +set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=skylake ) + # Build rule for "Ü" files. function( CompileUSource u_source_file out_object ) file( RELATIVE_PATH current_subdir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ) @@ -32,7 +35,7 @@ function( CompileUSource u_source_file out_object ) -o ${current_subdir}/${u_source_file_relative}.bc -MF ${CMAKE_CURRENT_BINARY_DIR}/${u_source_file_relative}.d --verify-module - ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} + ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} ${SPRACHE_COMPILER_ARCH_OPTIONS} --include-dir ${CMAKE_CURRENT_SOURCE_DIR}/../ustlib/ --include-dir ${CMAKE_CURRENT_SOURCE_DIR}/ --include-dir ${CMAKE_CURRENT_BINARY_DIR}/ @@ -51,7 +54,7 @@ function( CompileUSource u_source_file out_object ) -o ${current_subdir}/${u_source_file_relative}.o -MF ${CMAKE_CURRENT_BINARY_DIR}/${u_source_file_relative}.d --verify-module - ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} + ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} ${SPRACHE_COMPILER_ARCH_OPTIONS} --data-sections --function-sections # Put symbols into section in order to remove unused functions during linking. --symbols-visibility=hidden # Make functions and variables hidden to avoid exporting them in ELF shared libraries (*.so) --include-dir ${CMAKE_CURRENT_SOURCE_DIR}/../ustlib/ @@ -148,7 +151,7 @@ if( COMPILER1_LTO ) COMMAND Compiler${CURRENT_COMPILER_GENERATION} ${LEX_SYNT_LIB_OBJECTS} ${CODE_BUILDER_LIB_OBJECTS} ${LAUNCHERS_COMMON_OBJECTS} - ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} + ${SPRACHE_COMPILER_OPT_OPTIONS} ${SPRACHE_COMPILER_PIC_OPTIONS} ${SPRACHE_COMPILER_ARCH_OPTIONS} -o ${CODE_BUILDER_LIB_O} --input-filetype=bc -lto-mode=link From 1332375c2440d5d8004946b9a02ac3ee3d339e46 Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Sat, 5 Oct 2024 16:09:08 +0300 Subject: [PATCH 2/5] =?UTF-8?q?Kompilirujem=20tak=C5=BEe=20"C++"=20kod=20p?= =?UTF-8?q?od=20boljeje=20novyje=20pro=C3=A7essory.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 13 +++++++++++++ source/compiler1/CMakeLists.txt | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 3383a18dc..4306288aa 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -35,6 +35,19 @@ if( MSVC ) add_definitions( -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS ) endif() +# +# Global codegen options (for both Ü and dependencies). +# + +# Use a CPU from year 2015 or newer. It seems to be fine to avoid using older CPUs. +set( SPRACHE_TARGET_CPU_NAME skylake ) +set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=${SPRACHE_TARGET_CPU_NAME} ) + +if(MSVC) +else() + add_compile_options( -march=${SPRACHE_TARGET_CPU_NAME} ) +endif() + # # External dependencies # diff --git a/source/compiler1/CMakeLists.txt b/source/compiler1/CMakeLists.txt index b9861a24f..34557f03e 100644 --- a/source/compiler1/CMakeLists.txt +++ b/source/compiler1/CMakeLists.txt @@ -15,8 +15,6 @@ else() set( SPRACHE_COMPILER_OPT_OPTIONS -O2 ) endif() -# Use a CPU from year 2015 or newer. It seems to be fine to avoid using older CPUs. -set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=skylake ) # Build rule for "Ü" files. function( CompileUSource u_source_file out_object ) From 2cb5b16a2a112d0a3080c071044765cff77b2fa6 Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Sun, 6 Oct 2024 10:01:47 +0300 Subject: [PATCH 3/5] =?UTF-8?q?Pod=20"MSVC"=20sobirajem=20pod=20pro=C3=A7e?= =?UTF-8?q?ssory=20s=20"AVX2".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4306288aa..9e136fb44 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -44,6 +44,7 @@ set( SPRACHE_TARGET_CPU_NAME skylake ) set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=${SPRACHE_TARGET_CPU_NAME} ) if(MSVC) + add_compile_options( /arch:AVX2 ) else() add_compile_options( -march=${SPRACHE_TARGET_CPU_NAME} ) endif() From aa932ea2f249809d0f4d714f176eb69611f9dfa8 Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Sun, 6 Oct 2024 21:09:29 +0300 Subject: [PATCH 4/5] =?UTF-8?q?Vkl=C3=BCcajem=20neobhodimyje=20op=C3=A7ii?= =?UTF-8?q?=20sborki=20pod=20novyje=20pro=C3=A7essory=20toljko=20pod=20"x8?= =?UTF-8?q?6=5F64".?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/CMakeLists.txt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 9e136fb44..c84dd62a5 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -39,14 +39,21 @@ endif() # Global codegen options (for both Ü and dependencies). # -# Use a CPU from year 2015 or newer. It seems to be fine to avoid using older CPUs. -set( SPRACHE_TARGET_CPU_NAME skylake ) -set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=${SPRACHE_TARGET_CPU_NAME} ) +if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" ) + message( "Target architecture seems to be x86_64 (${CMAKE_SYSTEM_PROCESSOR}), turn on modern instructions support" ) + + # Use a CPU from year 2015 or newer. It seems to be fine to avoid using older CPUs. + set( SPRACHE_TARGET_CPU_NAME skylake ) + set( SPRACHE_COMPILER_ARCH_OPTIONS -mcpu=${SPRACHE_TARGET_CPU_NAME} ) + + if(MSVC) + add_compile_options( /arch:AVX2 ) + else() + add_compile_options( -march=${SPRACHE_TARGET_CPU_NAME} ) + endif() -if(MSVC) - add_compile_options( /arch:AVX2 ) else() - add_compile_options( -march=${SPRACHE_TARGET_CPU_NAME} ) + message( "Target architecture is not x86_64 (${CMAKE_SYSTEM_PROCESSOR})" ) endif() # From af756b8ebf3764202c8ae66f74f38a4cf8eefeca Mon Sep 17 00:00:00 2001 From: Panzerschrek Date: Sun, 6 Oct 2024 21:12:19 +0300 Subject: [PATCH 5/5] Pravki sborki "Emscripten". --- ci/build_emscripten.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_emscripten.sh b/ci/build_emscripten.sh index 41fab3fe0..836ad37ce 100755 --- a/ci/build_emscripten.sh +++ b/ci/build_emscripten.sh @@ -30,7 +30,7 @@ sed -i -e "s/-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE/-DLLVM_TARGET_IS_CROSSCOMPI # Configure build mkdir build &&\ cd build &&\ -cmake ../source/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=emcc -DCMAKE_CXX_COMPILER=emcc -DLLVM_SRC_DIR=../llvm-15.0.7.src/ -DU_EXTERNAL_LLVM_AS=$PWD/../clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-as -DU_EMSCRIPTEN=YES -DU_BUILD_COMPILER=NO -DU_BUILD_COMPILER1=NO -DU_BUILD_CPP_HEADER_CONVERTER=NO -DU_BUILD_LANGUAGE_SERVER=NO -DU_BUILD_TESTS=NO -DU_BUILD_PY_TESTS=NO -DU_BUILD_LINKAGE_TESTS=NO -DUBUILD_DOCS=NO -DU_BUILD_INTERPRETER=YES -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_BENCHMARKS=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_BUILD_DOCS=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_BUILD_TESTS=OFF &&\ +cmake ../source/ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PWD/../emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DEMSCRIPTEN_SYSTEM_PROCESSOR=wasm -DCMAKE_C_COMPILER=emcc -DCMAKE_CXX_COMPILER=emcc -DLLVM_SRC_DIR=../llvm-15.0.7.src/ -DU_EXTERNAL_LLVM_AS=$PWD/../clang+llvm-15.0.6-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-as -DU_EMSCRIPTEN=YES -DU_BUILD_COMPILER=NO -DU_BUILD_COMPILER1=NO -DU_BUILD_CPP_HEADER_CONVERTER=NO -DU_BUILD_LANGUAGE_SERVER=NO -DU_BUILD_TESTS=NO -DU_BUILD_PY_TESTS=NO -DU_BUILD_LINKAGE_TESTS=NO -DUBUILD_DOCS=NO -DU_BUILD_INTERPRETER=YES -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_BENCHMARKS=OFF -DLLVM_INCLUDE_BENCHMARKS=OFF -DLLVM_BUILD_DOCS=OFF -DLLVM_BUILD_EXAMPLES=OFF -DLLVM_BUILD_TESTS=OFF &&\ \ # Run build cmake --build .