Revision 94ad5427ad1ecd9480e41418ccfff21169486524 authored by Steven Johnson on 13 March 2023, 18:16:04 UTC, committed by Steven Johnson on 13 March 2023, 18:16:04 UTC
- printer.h uses `uint64_t`, so it needs to include something that ensures that type is defined. `HalideRuntime.h` is probably the right choice (since it always transitively includes `runtime_internal.h` when compiling runtime.

- HalideBuffer.h should completely elide itself when `COMPILING_HALIDE_RUNTIME` is defined, for a subtle reason: some compilation environments require that all .h files can be compiled 'standalone' -- ie, they include all prerequisites and can be included in any order. As it turns out, HalideBuffer.h has a previously unnoticed glitch that is now being caught by this:
    - It includes both `<cstring>` and `HalideRuntime.h`
    - but when `COMPILING_HALIDE_RUNTIME` is defined, `HalideRuntime.h` includes `runtime_internal.h`, which assumes that no std headers are included
    - as it happens, `runtime_internal.h` defines `strstr()` and `strchr()` in a way that doesn't match the std headers (they both return non-const `char *`, perversely enough) and we get a compile error for mismatched function prototypes

I think the neatest solution here is to just skip the entire contents of `HalideBuffer.h` in this situation, since none of its contents should ever be used inside the Halide runtime. (I could work around this situation on the google side by loosening the 'must be able to compile on its own' requirement in this case, but IMHO it's a good check and one that is worthy of keeping.)

The fact that our function prototypes are a mismatch for the 'correct' ones could be debated; IMHO our 'wrong' definitions are safer that the std and should be kept.
1 parent 78097a7
Raw File
CMakePresets.json
{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 22,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "base",
      "hidden": true,
      "binaryDir": "build/${presetName}",
      "installDir": "install/${presetName}"
    },
    {
      "name": "ci",
      "hidden": true,
      "inherits": "base",
      "toolchainFile": "${sourceDir}/cmake/toolchain.${presetName}.cmake",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "RelWithDebInfo"
      }
    },
    {
      "name": "windows-only",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "vcpkg",
      "hidden": true,
      "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
    },
    {
      "name": "vs2022",
      "hidden": true,
      "inherits": [
        "vcpkg",
        "windows-only"
      ],
      "generator": "Visual Studio 17 2022",
      "toolset": "host=x64"
    },
    {
      "name": "debug",
      "inherits": "base",
      "displayName": "Debug",
      "description": "Debug build with no special settings",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      }
    },
    {
      "name": "release",
      "inherits": "base",
      "displayName": "Release",
      "description": "Release build with no special settings",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    },
    {
      "name": "debian-debug",
      "inherits": "debug",
      "displayName": "Debian (Debug)",
      "description": "Debug build assuming Debian-provided dependencies",
      "cacheVariables": {
        "Halide_SHARED_LLVM": "ON"
      }
    },
    {
      "name": "debian-release",
      "inherits": "debian-debug",
      "displayName": "Debian (Release)",
      "description": "Release build assuming Debian-provided dependencies",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    },
    {
      "name": "win32",
      "inherits": [
        "vs2022",
        "base"
      ],
      "displayName": "Win32 (Visual Studio)",
      "description": "Visual Studio-based Win32 build with vcpkg dependencies.",
      "architecture": "Win32"
    },
    {
      "name": "win64",
      "inherits": [
        "vs2022",
        "base"
      ],
      "displayName": "Win64 (Visual Studio)",
      "description": "Visual Studio-based x64 build with vcpkg dependencies.",
      "architecture": "x64"
    },
    {
      "name": "package",
      "hidden": true,
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release",
        "LLVM_DIR": "$env{LLVM_DIR}",
        "Clang_DIR": "$env{Clang_DIR}",
        "LLD_DIR": "$env{LLD_DIR}",
        "WITH_TESTS": "NO",
        "WITH_TUTORIALS": "NO",
        "WITH_DOCS": "YES",
        "WITH_UTILS": "NO",
        "WITH_PYTHON_BINDINGS": "NO",
        "CMAKE_INSTALL_DATADIR": "share/Halide"
      }
    },
    {
      "name": "package-windows",
      "inherits": [
        "package",
        "vs2022"
      ],
      "displayName": "Package ZIP for Windows",
      "description": "Build for packaging Windows shared libraries.",
      "binaryDir": "${sourceDir}/build",
      "cacheVariables": {
        "BUILD_SHARED_LIBS": "YES",
        "CMAKE_INSTALL_BINDIR": "bin/$<CONFIG>",
        "CMAKE_INSTALL_LIBDIR": "lib/$<CONFIG>",
        "Halide_INSTALL_CMAKEDIR": "lib/cmake/Halide",
        "Halide_INSTALL_HELPERSDIR": "lib/cmake/HalideHelpers"
      }
    },
    {
      "name": "package-unix-shared",
      "inherits": "package",
      "displayName": "Package UNIX shared libs",
      "description": "Build for packaging UNIX shared libraries.",
      "binaryDir": "shared-Release",
      "cacheVariables": {
        "BUILD_SHARED_LIBS": "YES"
      }
    },
    {
      "name": "package-unix-static",
      "inherits": "package",
      "displayName": "Package UNIX static libs",
      "description": "Build for packaging UNIX static libraries.",
      "binaryDir": "static-Release",
      "cacheVariables": {
        "BUILD_SHARED_LIBS": "NO",
        "Halide_BUNDLE_LLVM": "YES"
      }
    },
    {
      "name": "linux-x64-asan",
      "inherits": "ci",
      "displayName": "ASAN (Linux x64)",
      "description": "Build everything with ASAN enabled",
      "cacheVariables": {
        "LLVM_ROOT": "$penv{LLVM_ROOT}"
      }
    }
  ],
  "buildPresets": [
    {
      "name": "debug",
      "configurePreset": "debug",
      "displayName": "Debug",
      "description": "Debug build with no special settings"
    },
    {
      "name": "release",
      "configurePreset": "release",
      "displayName": "Release",
      "description": "Release build with no special settings"
    },
    {
      "name": "linux-x64-asan",
      "configurePreset": "linux-x64-asan",
      "displayName": "ASAN (Linux x64)",
      "description": "Build everything with ASAN enabled"
    }
  ],
  "testPresets": [
    {
      "name": "debug",
      "configurePreset": "debug",
      "displayName": "Debug",
      "description": "Test everything with Debug build",
      "output": {
        "outputOnFailure": true
      }
    },
    {
      "name": "release",
      "configurePreset": "release",
      "displayName": "Release",
      "description": "Test everything with Release build",
      "output": {
        "outputOnFailure": true
      }
    },
    {
      "name": "linux-x64-asan",
      "configurePreset": "linux-x64-asan",
      "displayName": "ASAN (Linux x64)",
      "description": "Test everything with ASAN enabled",
      "environment": {
        "ASAN_OPTIONS": "detect_leaks=0:detect_container_overflow=0"
      },
      "output": {
        "outputOnFailure": true
      }
    }
  ]
}
back to top