]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Make it possible to disable UNALIGNED[64]_OK in cmake.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 11 Sep 2020 19:48:46 +0000 (21:48 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Mon, 14 Sep 2020 10:03:15 +0000 (12:03 +0200)
Enable testing with -O3 and unaligned reads disabled.

.github/workflows/cmake.yml
CMakeLists.txt
README.md

index f062ddaf3336460a4ed388a4142002fca423d753..220db70c29d318aa52edc9ee124062eb01828226 100644 (file)
@@ -9,7 +9,8 @@ jobs:
       matrix:
         name: [
           Ubuntu GCC,
-          Ubuntu GCC OSB -O1,
+          Ubuntu GCC OSB -O1 No Unaligned,
+          Ubuntu GCC -O3 No Unaligned,
           Ubuntu GCC Link Zlib,
           Ubuntu GCC No AVX2,
           Ubuntu GCC No SSE2,
@@ -55,15 +56,22 @@ jobs:
             cmake-args: -DWITH_SANITIZERS=ON
             codecov: ubuntu_gcc
 
-          - name: Ubuntu GCC OSB -O1
+          - name: Ubuntu GCC OSB -O1 No Unaligned
             os: ubuntu-latest
             compiler: gcc
-            cmake-args: -DWITH_SANITIZERS=ON
+            cmake-args: -DWITH_SANITIZERS=ON -DWITH_UNALIGNED=OFF
             build-dir: ../build
             build-src-dir: ../zlib-ng
             codecov: ubuntu_gcc_osb
             cflags: -O1 -g3
 
+          - name: Ubuntu GCC -O3 No Unaligned
+            os: ubuntu-latest
+            compiler: gcc
+            cmake-args: -DWITH_SANITIZERS=ON -DWITH_UNALIGNED=OFF
+            codecov: ubuntu_gcc_o3
+            cflags: -O3
+
           - name: Ubuntu GCC Link Zlib
             os: ubuntu-latest
             compiler: gcc
index db1c60ab07e6b0f4bb773d46a8e5c2388a53363f..4ef0b563a020b2759bf1131e79155b7cf8c4fde4 100644 (file)
@@ -87,6 +87,7 @@ option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF)
 option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF)
 option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF)
 option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF)
+option(WITH_UNALIGNED "Support unaligned reads on platforms that support it" ON)
 
 if(BASEARCH_ARM_FOUND)
     option(WITH_ACLE "Build with ACLE" ON)
@@ -116,6 +117,7 @@ mark_as_advanced(FORCE
     WITH_POWER8
     WITH_INFLATE_STRICT
     WITH_INFLATE_ALLOW_INVALID_DIST
+    WITH_UNALIGNED
     INSTALL_UTILS
     )
 
@@ -266,37 +268,41 @@ if(NOT MSVC AND NOT CMAKE_C_FLAGS MATCHES "([\\/\\-]O)3")
 endif()
 
 # Set architecture alignment requirements
-if(BASEARCH_ARM_FOUND OR (BASEARCH_PPC_FOUND AND "${ARCH}" MATCHES "powerpc64le") OR BASEARCH_X86_FOUND)
-    if(NOT DEFINED UNALIGNED_OK)
-        set(UNALIGNED_OK TRUE)
+if(WITH_UNALIGNED)
+    if(BASEARCH_ARM_FOUND OR (BASEARCH_PPC_FOUND AND "${ARCH}" MATCHES "powerpc64le") OR BASEARCH_X86_FOUND)
+        if(NOT DEFINED UNALIGNED_OK)
+            set(UNALIGNED_OK TRUE)
+        endif()
     endif()
-endif()
-if(UNALIGNED_OK)
-    add_definitions(-DUNALIGNED_OK)
-    message(STATUS "Architecture supports unaligned reads")
-endif()
-if(BASEARCH_ARM_FOUND)
-    if(NOT DEFINED UNALIGNED64_OK)
-        if("${ARCH}" MATCHES "(arm(v[8-9])?|aarch64)")
-            set(UNALIGNED64_OK TRUE)
+    if(UNALIGNED_OK)
+        add_definitions(-DUNALIGNED_OK)
+        message(STATUS "Architecture supports unaligned reads")
+    endif()
+    if(BASEARCH_ARM_FOUND)
+        if(NOT DEFINED UNALIGNED64_OK)
+            if("${ARCH}" MATCHES "(arm(v[8-9])?|aarch64)")
+                set(UNALIGNED64_OK TRUE)
+            endif()
         endif()
     endif()
-endif()
-if(BASEARCH_PPC_FOUND)
-    if(NOT DEFINED UNALIGNED64_OK)
-        if("${ARCH}" MATCHES "powerpc64le")
+    if(BASEARCH_PPC_FOUND)
+        if(NOT DEFINED UNALIGNED64_OK)
+            if("${ARCH}" MATCHES "powerpc64le")
+                set(UNALIGNED64_OK TRUE)
+            endif()
+        endif()
+    endif()
+    if(BASEARCH_X86_FOUND)
+        if(NOT DEFINED UNALIGNED64_OK)
             set(UNALIGNED64_OK TRUE)
         endif()
     endif()
-endif()
-if(BASEARCH_X86_FOUND)
-    if(NOT DEFINED UNALIGNED64_OK)
-        set(UNALIGNED64_OK TRUE)
+    if(UNALIGNED64_OK)
+        add_definitions(-DUNALIGNED64_OK)
+        message(STATUS "Architecture supports unaligned reads of > 4 bytes")
     endif()
-endif()
-if(UNALIGNED64_OK)
-    add_definitions(-DUNALIGNED64_OK)
-    message(STATUS "Architecture supports unaligned reads of > 4 bytes")
+else()
+    message(STATUS "Unaligned reads manually disabled")
 endif()
 
 # Apply warning compiler flags
index d1dfa23d35889832caa8190462d87ca73c226e16..901af0781581a598cfa4b6bac58824730e94f264 100644 (file)
--- a/README.md
+++ b/README.md
@@ -191,7 +191,6 @@ Advanced Build Options
 | CMake                           | configure             | Description                                                         | Default                |
 |:--------------------------------|:----------------------|:--------------------------------------------------------------------|------------------------|
 | ZLIB_DUAL_LINK                  |                       | Dual link tests with system zlib                                    | OFF                    |
-| UNALIGNED_OK                    |                       | Allow unaligned reads                                               | ON (x86, arm)          |
 |                                 | --force-sse2          | Assume SSE2 instructions are always available                       | ON (x86), OFF (x86_64) |
 | WITH_AVX2                       |                       | Build with AVX2 intrinsics                                          | ON                     |
 | WITH_SSE2                       |                       | Build with SSE2 intrinsics                                          | ON                     |
@@ -202,6 +201,7 @@ Advanced Build Options
 | WITH_POWER8                     |                       | Build with POWER8 optimisations                                     | ON                     |
 | WITH_DFLTCC_DEFLATE             | --with-dfltcc-deflate | Use DEFLATE COMPRESSION CALL instruction for compression on IBM Z   | OFF                    |
 | WITH_DFLTCC_INFLATE             | --with-dfltcc-inflate | Use DEFLATE COMPRESSION CALL instruction for decompression on IBM Z | OFF                    |
+| WITH_UNALIGNED                  |                       | Allow optimizations that use unaligned reads if safe on current arch| ON                    |
 | WITH_INFLATE_STRICT             |                       | Build with strict inflate distance checking                         | OFF                    |
 | WITH_INFLATE_ALLOW_INVALID_DIST |                       | Build with zero fill for inflate invalid distances                  | OFF                    |
 | INSTALL_UTILS                   |                       | Copy minigzip and minideflate during install                        | OFF                    |