Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error on manylinux_2_28_x64 with GCC 12.1.1 #69

Closed
dzenanz opened this issue Dec 2, 2022 · 56 comments · Fixed by InsightSoftwareConsortium/ITKIOOMEZarrNGFF#14
Closed

Comments

@dzenanz
Copy link

dzenanz commented Dec 2, 2022

This happens with the latest version, efca7ed.

...
[811/2057] Building C object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/compress/zstdmt_compress.c.o
[812/2057] Building C object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/compress/zstd_opt.c.o
[813/2057] Building ASM object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o
FAILED: _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o 
/opt/rh/gcc-toolset-12/root/bin//as --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-source/ITK/Modules/IO/HDF5/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/work/ITK-source/ITK/Modules/ThirdParty/ZLIB/src -I/work/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build/lib -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib -O3 -DNDEBUG -fPIC -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/common --MD _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S
/opt/rh/gcc-toolset-12/root/bin//as: invalid option -- 'N'
[814/2057] Building C object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress.c.o
[815/2057] Building C object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/compress/zstd_lazy.c.o
ninja: build stopped: subcommand failed.
  File "/opt/python/cp38-cp38/lib/python3.8/site-packages/skbuild/setuptools_wrap.py", line 551, in setup

The full build log is here. This is somewhat a continuation of #65.

@laramiel
Copy link
Collaborator

laramiel commented Dec 4, 2022

I think that we want CMake to use CC for the assembler. We may need to add something like:

set_property(SOURCE huf_decompress_amd64.S APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

You might try adding this arg to third_party/net_zlib/workspace.bzl in the repo.maybe() call, just after bazel_to_cmake = {}.

  cmakelists_prefix="""
 SET(ASM_OPTIONS "-x assembler-with-cpp")
 SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" )
 """,

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

I have seen your edit just now. Adding

SET(ASM_OPTIONS "-x assembler-with-cpp")
SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" )

before and after FetchContent calls in my code did not fix it. I will now try adding updated suggestion to .bzl file.

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

The above suggestion will do basically the same thing you attempted.
Ok, if you sync my latest commit, you could try this:

Add the following code at line 193 (inside the not header_only condition, but after this):

if not header_only:
_builder.addtext(f"""\n
add_library({target_name})
target_sources({target_name} PRIVATE{_SEP}{quote_list(cc_srcs , separator=_SEP)})
set_property(TARGET {target_name} PROPERTY LINKER_LANGUAGE "CXX")
""")

     for f in cc_srcs:
       if f.endswith(".s") or f.endswith(".S"):
         _builder.addtext(
           f"""set_property(SOURCE {quote(f)} APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")\n""")

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

I get a brand new error during configure step when I do that:

...
-- [Blosc] Found ZLIB: zlib  
Added toolchain @rules_perl//:current_toolchain
Loading /home/runner/work/ITKIOOMEZarrNGFF/build/_deps/zstd-src/BUILD.bazel
Using library: @com_google_tensorstore//bazel:utils.bzl at /home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/bazel/utils.bzl
Loading /home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/bazel/utils.bzl
Analyze: @net_zstd//:linux_x86_64_clang
Analyze: @net_zstd//:linux_x86_64_gcc
Analyze: @net_zstd//:macos_x86_64
Analyze: @net_zstd//:zstd_asm_supported
Analyze: @net_zstd//:zstdlib
Traceback (most recent call last):
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/evaluation.py", line 246, in get_optional_target_info
    rule_info.impl()
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/native_rules_cc.py", line 46, in <lambda>
    lambda: _cc_library_impl(context, target, **kwargs),
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/native_rules_cc.py", line 72, in _cc_library_impl
    emit_cc_library(
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/emit_cc.py", line 196, in emit_cc_library
    f"""set_property(SOURCE {quote(f)} APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")\n""")
NameError: name 'quote' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake.py", line 41, in <module>
    sys.exit(bazel_to_cmake.main.main())
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/main.py", line 184, in main
    state.analyze(sorted(targets_to_analyze))
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/evaluation.py", line 175, in analyze
    self.get_target_info(target)
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/evaluation.py", line 267, in get_target_info
    info = self.get_optional_target_info(target_id)
  File "/home/runner/work/ITKIOOMEZarrNGFF/build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/evaluation.py", line 253, in get_optional_target_info
    raise ValueError(
ValueError: Error analyzing @net_zstd//:zstdlib  with RuleInfo(outs=[], impl=<function cc_library.<locals>.<lambda> at 0x7f5a808cf820>, kind='cc_library')
CMake Error at /home/runner/work/ITKIOOMEZarrNGFF/build/_deps/zstd-src/CMakeLists.txt:26 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 1"



-- Configuring incomplete, errors occurred!
See also "/home/runner/work/ITKIOOMEZarrNGFF/build/CMakeFiles/CMakeOutput.log".
See also "/home/runner/work/ITKIOOMEZarrNGFF/build/CMakeFiles/CMakeError.log".

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

Changing the offending line into f"""set_property(SOURCE "{f}" APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")\n""") gets me past that error.

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

yeah, quote is defined in cmake_builder, and so it would need to be imported. So, after that, does it build?

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

That still has the yasm/nasm error.

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

I see that now. In updating other things I managed to regress the version of docker image. I just pushed an update. The new progress is here: https://github.com/dzenanz/ITKIOOMEZarrNGFF/actions/runs/3624503022/jobs/6111552269.

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

Ok, that doesn't solve it. Perhaps try adding another line:

_builder.addtext(
f"""set_property(SOURCE "{f}" PROPERTY LANGUAGE ASM)
set_property(SOURCE "{f}" APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
""")

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

It may just be that we're missing the proper language target. Maybe all we need is to edit third_party/net_zlib/workspace.bzl and add:

cmake_languages = ["C", "ASM"],

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

But isn't the error message complaining about compiling zstd? Are you sure we need to focus on zlib?

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

@laramiel
Copy link
Collaborator

laramiel commented Dec 5, 2022

Yeah, you're right. sorry. net_zstd/workspace.bzl

@dzenanz
Copy link
Author

dzenanz commented Dec 5, 2022

I am retrying with cmake_languages = ["C", "ASM"], in zstd. New progress at: https://github.com/dzenanz/ITKIOOMEZarrNGFF/actions/runs/3624767759/jobs/6112413590.

@laramiel
Copy link
Collaborator

laramiel commented Dec 6, 2022

Still getting /bin/as. Another thing to try In the net_zlib workspace.bzl file, add the prefix as:

prefix = "SET(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})"

@dzenanz
Copy link
Author

dzenanz commented Dec 6, 2022

@dzenanz
Copy link
Author

dzenanz commented Dec 6, 2022

@dzenanz
Copy link
Author

dzenanz commented Dec 6, 2022

@dzenanz
Copy link
Author

dzenanz commented Dec 6, 2022

I tried using GCC-11, and declaring language together with CMake project specification: project(IOOMEZarrNGFF CXX C ASM). Neither helped: https://github.com/dzenanz/ITKIOOMEZarrNGFF/actions/runs/3631789807/jobs/6126862437.

@dzenanz
Copy link
Author

dzenanz commented Dec 7, 2022

What would be the best way to disable ZSTD from building? From CMake GUI I see just a few related options: Zstd_DIR, TENSORSTORE_USE_SYSTEM_ZSTD, FETCHCONTENT_SOURCE_DIR_ZSTD, FETCHCONTENT_UPDATES_DISCONNECTED_ZSTD. Is there an easy way to disable it, or do I have to modify TensorStore's build system to accomplish that?

@laramiel
Copy link
Collaborator

laramiel commented Dec 7, 2022

Use TENSORSTORE_USE_SYSTEM_ZSTD, which will fall back to cmake's find_package() call.

@laramiel
Copy link
Collaborator

laramiel commented Dec 7, 2022

Looking at this again, perhaps I've been attacking the problem from the wrong angle. I think that I need to figure out how the -DNDEBUG was added to the command line instead of trying to force CMake to use the C preprocessor. The overall command is building in release mode, so it seems like adding the flags to c++ makes sense; so why are they in there?

/opt/python/cp38-cp38/bin/python setup.py bdist_wheel --build-type Release -G Ninja -- -DITK_DIR:PATH=/work/ITK-cp38-cp38-manylinux_2_28_x64 -DITK_USE_SYSTEM_SWIG:BOOL=ON -DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel -DSWIG_EXECUTABLE:FILEPATH=/work/ITK-cp38-cp38-manylinux_2_28_x64/Wrapping/Generators/SwigInterface/swig/bin/swig -DCMAKE_CXX_COMPILER_TARGET:STRING=x86_64-linux-gnu -DCMAKE_INSTALL_LIBDIR:STRING=lib -DBUILD_TESTING:BOOL=OFF -DPython3_EXECUTABLE:FILEPATH=/opt/python/cp38-cp38/bin/python -DPython3_INCLUDE_DIR:PATH=/opt/python/cp38-cp38/bin/../include/python3.8

From your cmake build directory, is it possible to get _deps/zstd-build/build_rules.cmake? That would let me see if the target Zstd_zstdlib has had these flags added, or if it's at a higher level in the CMakeLists.txt file.

@dzenanz
Copy link
Author

dzenanz commented Dec 7, 2022

Here is output from a local build:

-- Performing Test COMPILER_HAS_DEPRECATED_ATTR - Success
-- Found SWIG: /work/ITK-cp310-cp310-manylinux_2_28_x64/Wrapping/Generators/SwigInterface/swig/bin/swig (found version "4.0.2")  
-- Performing Test ITK_UNDEFINED_SYMBOLS_ALLOWED - Success
-- IOOMEZarrNGFF: Creating module.
-- IOOMEZarrNGFF: Creating itkOMEZarrNGFFImageIO submodule.
-- Configuring done
-- Generating done
-- Build files have been written to: /work/_skbuild/linux-x86_64-3.10/cmake-build
[810/2055] Building ASM object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o
FAILED: _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o 
/opt/rh/gcc-toolset-11/root/bin//as --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-source/ITK/Modules/IO/HDF5/include -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src -I/work/ITK-cp310-cp310-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/work/ITK-source/ITK/Modules/ThirdParty/ZLIB/src -I/work/include -I/work/_skbuild/linux-x86_64-3.10/cmake-build/include -I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src -I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-build -I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-build/lib -I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib -O3 -DNDEBUG -fPIC -I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common -x assembler-with-cpp --MD _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S
/opt/rh/gcc-toolset-11/root/bin//as: invalid option -- 'N'
[815/2055] Building C object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/compress/zstd_lazy.c.o
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "/opt/python/cp310-cp310/lib/python3.10/site-packages/skbuild/setuptools_wrap.py", line 640, in setup
    cmkr.make(make_args, install_target=cmake_install_target, env=env)
  File "/opt/python/cp310-cp310/lib/python3.10/site-packages/skbuild/cmaker.py", line 670, in make
    self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
  File "/opt/python/cp310-cp310/lib/python3.10/site-packages/skbuild/cmaker.py", line 701, in make_impl
    raise SKBuildError(

An error occurred while building with CMake.
  Command:
    cmake --build . --target install --config Release --
  Install target:
    install
  Source directory:
    /work
  Working directory:
    /work/_skbuild/linux-x86_64-3.10/cmake-build
Please check the install target is valid and see CMake's output for more information.
+ exit 1
dzenan@corista:~/zarr/ITKIOOMEZarrNGFF$

Essentially the same as in CI. Content of _deps/zstd-build/build_rules.cmake is below. Attaching .cmake file is not supported on GitHub.

set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/bazel/utils.bzl"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/__init__.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/bazel_skylib.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/bazel_tools_repo_utils.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/default.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/helpers.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/local_mirror.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/rules_cc.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/rules_nasm.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/rules_perl.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/rules_proto.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/bzl_library/third_party_http_archive.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/cmake_builder.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/cmake_target.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/emit_cc.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/evaluation.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/main.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/native_rules.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/native_rules_cc.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/native_rules_proto.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/package.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/platforms.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/__init__.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/bazel_glob.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/bazel_globals.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/bazel_target.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/common_providers.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/depset.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/ignored.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/invocation_context.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/label.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/provider.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/rule.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/select.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/starlark/struct.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/util.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/variable_substitution.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/tensorstore-src/tools/cmake/bazel_to_cmake/workspace.py"
    "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/BUILD.bazel")


add_library(Zstd_zstdlib)
target_sources(Zstd_zstdlib PRIVATE
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/debug.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/entropy_common.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/error_private.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/fse_decompress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/pool.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/threading.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/xxhash.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common/zstd_common.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/fse_compress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/hist.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/huf_compress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_compress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_compress_literals.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_compress_sequences.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_compress_superblock.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_double_fast.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_fast.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_lazy.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_ldm.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstd_opt.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/compress/zstdmt_compress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/zstd_ddict.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/zstd_decompress.c"
        "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/zstd_decompress_block.c")
set_property(TARGET Zstd_zstdlib PROPERTY LINKER_LANGUAGE "CXX")
set_property(SOURCE "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S" PROPERTY LANGUAGE ASM)
set_property(SOURCE "/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S" APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
target_compile_definitions(Zstd_zstdlib PRIVATE "XXH_NAMESPACE=ZSTD_")
target_compile_definitions(Zstd_zstdlib PUBLIC "ZSTDLIB_VISIBLE=" "ZSTDLIB_HIDDEN=")
target_compile_options(Zstd_zstdlib PRIVATE "-I/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib/common")
target_link_libraries(Zstd_zstdlib PUBLIC
        "Threads::Threads"
        "m")
target_include_directories(Zstd_zstdlib PUBLIC
        "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>"
        "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>"
        "$<BUILD_INTERFACE:/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-build/lib>"
        "$<BUILD_INTERFACE:/work/_skbuild/linux-x86_64-3.10/cmake-build/_deps/zstd-src/lib>")
target_compile_features(Zstd_zstdlib PUBLIC cxx_std_17)
target_compile_options(Zstd_zstdlib PUBLIC "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-deprecated-declarations>" "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-sign-compare>" "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-but-set-parameter>" "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-maybe-uninitialized>" "$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unknown-warning-option>" "$<$<COMPILE_LANGUAGE:CXX>:-fsized-deallocation>")
add_library(Zstd::Zstd ALIAS Zstd_zstdlib)

@laramiel
Copy link
Collaborator

laramiel commented Dec 8, 2022

Thanks. The failed build still has -DNDEBUG and it doesn't appear in the build_rules.cmake file. So that means that it's set elsewhere. Can you look for NDEBUG in the bazel_to_cmake_vars.json file (which is basically a dump of all the cmake variables set when the tensorstore CMake begins? For reference, on my machine I see these lines:

$ grep NDEBUG *.json
"CMAKE_CXX_FLAGS_MINSIZEREL":"-Os -DNDEBUG",
"CMAKE_CXX_FLAGS_MINSIZEREL_INIT":" -Os -DNDEBUG",
"CMAKE_CXX_FLAGS_RELEASE":"-O3 -DNDEBUG",
"CMAKE_CXX_FLAGS_RELEASE_INIT":" -O3 -DNDEBUG",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO":"-O2 -g -DNDEBUG",
"CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT":" -O2 -g -DNDEBUG",

@dzenanz
Copy link
Author

dzenanz commented Dec 8, 2022

Trying to pretty-print this file so I can extract relevant part fails in Notepad++:

---------------------------
Error while trying to parse JSON
---------------------------
Could not parse the document because of error
System.ArgumentException: An item with the same key has already been added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at JSON_Tools.JSON_Tools.JsonParser.ParseObject(String inp)
   at JSON_Tools.JSON_Tools.JsonParser.ParseSomething(String inp)
   at JSON_Tools.JSON_Tools.JsonParser.Parse(String inp)
   at Kbg.NppPluginNET.Main.TryParseJson(Boolean is_json_lines)
---------------------------
OK   
---------------------------

So I attach the whole file: bazel_to_cmake_vars.zip

@laramiel
Copy link
Collaborator

That didn't seem to give me any hints, sorry. As best as I can tell, right now the C_FLAGS are being added to the ASM build, but I'm not sure why that happens.

@dzenanz
Copy link
Author

dzenanz commented Dec 12, 2022

Thanks for your help so far.

What would be the best way to disable ZSTD from building?

Do you have an answer to this question I asked above?

@laramiel
Copy link
Collaborator

laramiel commented Dec 12, 2022

Adding -DTENSORSTORE_USE_SYSTEM_ZSTD=1 to the cmake invocation should do it.

@dzenanz
Copy link
Author

dzenanz commented Dec 13, 2022

Updating to latest (10ae2c2) didn't help. Still the same error.

@dzenanz
Copy link
Author

dzenanz commented Dec 13, 2022

I have a new attempt, building zstd via fetch_content and then trying to plug that as "system" zstd to tensorstore. However this doesn't even build locally. Here is the complete configure log:

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.9") found components: Interpreter Development.Module Development.Embed 
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.7") found components: Interpreter 
ITK is setting IOOMEZarrNGFF's MSVC_RUNTIME_LIBRARY to dynamic
ZSTD VERSION: 1.5.2
CMAKE_INSTALL_PREFIX: C:/Program Files/HDF_Group/HDF5/1.12.2
CMAKE_INSTALL_LIBDIR: lib
ZSTD_LEGACY_SUPPORT not defined!
ZSTD_MULTITHREAD_SUPPORT is disabled
CMake Deprecation Warning at src/CMakeLists.txt:46 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


Zstd_LIBRARY == C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/hdf5-build/bin/$(Configuration)/zstd_static.lib
Found Python3: C:/Program Files/Python39/python.exe (found version "3.9.13") found components: Interpreter 
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Zstd (missing: Zstd_LIBRARY)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/tensorstore-src/tools/cmake/FindZstd.cmake:35 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/blosc-build/build_rules.cmake:45 (find_package)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/blosc-src/CMakeLists.txt:35 (include)


Configuring incomplete, errors occurred!
See also "C:/Dev/ITKIOOMEZarrNGFF-vs19/CMakeFiles/CMakeOutput.log".
See also "C:/Dev/ITKIOOMEZarrNGFF-vs19/CMakeFiles/CMakeError.log".

When I was doing an incremental build, C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/hdf5-build/bin/$(Configuration)/zstd_static.lib existed (for both Debug and RelWithDebInfo configurations), and the error occurred later on in the configure process, complaining that it could not find Zstd_LIBRARY.

@dzenanz
Copy link
Author

dzenanz commented Dec 15, 2022

Any suggestions?

@jbms
Copy link
Collaborator

jbms commented Dec 15, 2022

If you want to use zstd via FetchContent you should not specify TENSORSTORE_USE_SYSTEM_ZSTD; that expects to find an existing zstd library at configure time, but with FetchContent the library won't yet be built --- instead it should be sufficient to call FetchContent before the tensorstore build gets loaded (via FetchContent_MakeAvailable), since the first FetchContent call for a given package name takes precedence in CMake.
Additionally you will need to define a Zstd::Zstd alias target.

It is our intention that this should work (substituting your own build of a cmake package that tensorstore depends on), but we haven't tested it.

It would be great to figure out what the issue is with our zstd build, though. Probably trying to find a minimal standalone CMakeLists.txt that reproduces the issue on manylinux_2_28_x64 would be very helpful in getting to the bottom of it.

@dzenanz
Copy link
Author

dzenanz commented Dec 15, 2022

Changing according to this advice results in:

...
ZSTD VERSION: 1.5.2
CMAKE_INSTALL_PREFIX: C:/Program Files/HDF_Group/HDF5/1.12.2
CMAKE_INSTALL_LIBDIR: lib
ZSTD_LEGACY_SUPPORT not defined!
ZSTD_MULTITHREAD_SUPPORT is disabled
CMake Error at C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/zstd_lib-build/zstdConfig.cmake:1 (include):
  include could not find requested file:

    C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/zstd_lib-build/zstdTargets.cmake
Call Stack (most recent call first):
  src/CMakeLists.txt:44 (find_package)


Found Python3: C:/Program Files/Python39/python.exe (found version "3.9.13") found components: Interpreter 
CMake Error at C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/zstd-build/build_rules.cmake:84 (add_library):
  add_library cannot create ALIAS target "Zstd::Zstd" because another target
  with the same name already exists.
Call Stack (most recent call first):
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/zstd-src/CMakeLists.txt:35 (include)

Indeed, zstdTargets.cmake does not exist at configure time.

If I uncomment set(TENSORSTORE_USE_SYSTEM_ZSTD ON), then the error is quite similar to before (with the addition of complaint for zstdTargets.cmake).

@dzenanz
Copy link
Author

dzenanz commented Dec 15, 2022

reproduces the issue on manylinux_2_28_x64

Is there a way to rip out just zstd? It would make testing easier. Looking at C:\Dev\ITKIOOMEZarrNGFF-vs19\_deps\zstd-src\CMakeLists.txt, it contains full paths such as C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/tensorstore-src/tools/cmake/bazel_to_cmake.py.

@laramiel
Copy link
Collaborator

As for ripping out ZSTD, we don't really have a built-in option to do that; it's linked into litiff and blosc.

So you could, perhaps, remove it from libtiff.BUILD.bazel and change the ZSTD_SUPPORT=1 define there, also remove it from org_blosc_cblosc/bundled.BUILD.bazel as well.

@dzenanz
Copy link
Author

dzenanz commented Dec 16, 2022

Applying the first suggestion (commit here) yields a very similar error to before:

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.9") found components: Interpreter Development.Module Development.Embed 
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.7") found components: Interpreter 
ITK is setting IOOMEZarrNGFF's MSVC_RUNTIME_LIBRARY to dynamic
Found Python3: C:/Program Files/Python39/python.exe (found version "3.9.13") found components: Interpreter 
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Zstd (missing: Zstd_LIBRARY Zstd_INCLUDE_DIR)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/tensorstore-src/tools/cmake/FindZstd.cmake:35 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/blosc-build/build_rules.cmake:45 (find_package)
  C:/Dev/ITKIOOMEZarrNGFF-vs19/_deps/blosc-src/CMakeLists.txt:35 (include)

@dzenanz
Copy link
Author

dzenanz commented Dec 16, 2022

Trying to build zstd during configure causes some infinite recursion:

Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.9") found components: Interpreter Development.Module Development.Embed 
Found Python3: C:/Program Files/Python39/python.exe (found suitable version "3.9.13", minimum required is "3.7") found components: Interpreter 
ITK is setting IOOMEZarrNGFF's MSVC_RUNTIME_LIBRARY to dynamic
ZSTD VERSION: 1.5.2
CMAKE_INSTALL_PREFIX: C:/Program Files/HDF_Group/HDF5/1.12.2
CMAKE_INSTALL_LIBDIR: lib
ZSTD_LEGACY_SUPPORT not defined!
ZSTD_MULTITHREAD_SUPPORT is disabled
Building zstd
Building zstd


Building zstd


Building zstd


Building zstd


Building zstd


Building zstd

@dzenanz
Copy link
Author

dzenanz commented Dec 19, 2022

@laramiel any further suggestions?

@jbms
Copy link
Collaborator

jbms commented Dec 19, 2022

I think it might help to compare the compile commands issued for zstd between manylinux2 and a working Linux configuration.

I suspect something is going wrong with the CMake asm compiler configuration.

@dzenanz
Copy link
Author

dzenanz commented Dec 22, 2022

Here is the failing command:
/opt/rh/gcc-toolset-12/root/bin//as --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-source/ITK/Modules/IO/HDF5/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/work/ITK-source/ITK/Modules/ThirdParty/ZLIB/src -I/work/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build/lib -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib -O3 -DNDEBUG -fPIC -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/common --MD _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S

and successful command:
/usr/bin/cc -DXXH_NAMESPACE=ZSTD_ -DZSTDLIB_HIDDEN="" -DZSTDLIB_VISIBLE="" -I/home/dzenan/ITK-git/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/Eigen3/src -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/KWSys/src -I/home/dzenan/ITK-git/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/home/dzenan/ITK-git/Modules/ThirdParty/VNL/src/vxl/vcl -I/home/dzenan/ITK-git/Modules/ThirdParty/VNL/src/vxl/core -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/VNL/src/vxl/vcl -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/VNL/src/vxl/core -I/home/dzenan/ITK-git-rel/Modules/Core/Common -I/home/dzenan/ITK-git/Modules/Core/Common/include -I/home/dzenan/ITK-git-rel/Modules/IO/ImageBase -I/home/dzenan/ITK-git/Modules/IO/ImageBase/include -I/home/dzenan/ITK-git/Modules/IO/HDF5/include -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/ZLIB/src -I/home/dzenan/ITK-git-rel/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/home/dzenan/ITK-git/Modules/ThirdParty/ZLIB/src -I/home/dzenan/ITKIOOMEZarrNGFF/include -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/include -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-build -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-build/lib -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-src -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-src/lib -O2 -g -DNDEBUG -fPIC -I/home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-src/lib/common -MD -MT _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -MF _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /home/dzenan/ITKIOOMEZarrNGFF-rwdi/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S.

@dzenanz
Copy link
Author

dzenanz commented Dec 22, 2022

So you are right, that the trick is that cc should be invoked to compile it, and not as. Which just brings us back to how.

@jbms
Copy link
Collaborator

jbms commented Dec 24, 2022

The issue seems to be that in your build, CMake is detecting the assembler as "Found assembler: /opt/rh/gcc-toolset-12/root/bin//as" while for a working build it needs to use "/opt/rh/gcc-toolset-12/root/bin//cc" instead.

I believe that normally CMake will attempt to use the C compiler for assembly by default, but for some reason that is not happening here.

I tried to reproduce that with a very simple CMakeLists.txt running in the manylinux_2_28_x86_64 docker image, but could not --- the assembler was always detected as "/opt/rh/gcc-toolset-12/root/bin//cc".

If you change your build to specify --debug-output --trace-expand as additional options to CMake, that might help in figuring out why as is being detected instead of cc.

In the past I have observed unusual behavior if all of the enable_language calls don't happen at the top level, but I am not sure if that is related to the issue here. But you could try adding:

enable_language(C)
enable_language(CXX)
enable_language(ASM_NASM)
enable_language(ASM)

to your top-level CMakeLists.txt.

@dzenanz
Copy link
Author

dzenanz commented Dec 27, 2022

@thewtex suggested that assembler choice is probably coming from toolchain being used for package building. So I tried overriding it in my code. That works, but it only produces a different error:

[813/2055] Building ASM object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o
FAILED: _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o 
/opt/rh/gcc-toolset-11/root/bin//gcc --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-source/ITK/Modules/IO/HDF5/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/work/ITK-source/ITK/Modules/ThirdParty/ZLIB/src -I/work/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build/lib -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib -O3 -DNDEBUG -fPIC -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/common --MD _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--MD’; did you mean ‘-MD’?

@dzenanz
Copy link
Author

dzenanz commented Dec 27, 2022

@jbms Just setting the 4 languages makes no difference, I still get /opt/rh/gcc-toolset-11/root/bin//as: invalid option -- 'N'.

@jbms
Copy link
Collaborator

jbms commented Dec 28, 2022

Okay, looks like the issue is indeed the toolchain file. I think it is a bug to specify CMAKE_ASM_COMPILER=as in the toolchain file, because that prevents compiling asm sources that require the C preprocessor (typically such sources use a ".S" extension).

Unfortunately I think the way you are attempting to override CMAKE_ASM_COMPILER does not work --- CMake has already run its compiler detection logic (which appears to check if the asm compiler basename is "as") and determined that it should use "--defsym" rather than "-D", "--MD" instead of "-MD", etc. I'm not sure if there is a way to override the toolchain file --- instead you may just need to modify the toolchain file.

@dzenanz
Copy link
Author

dzenanz commented Dec 29, 2022

Trying to unset CMAKE_ASM_COMPILER within my code does not work, with the same error as before:

[1023/2055] Building ASM object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o
FAILED: _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o 
/opt/rh/gcc-toolset-11/root/bin//as --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp37-cp37m-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-sourc...
/opt/rh/gcc-toolset-11/root/bin//as: invalid option -- 'N'

Inspired by relevant CMake code, trying to set both CMAKE_ASM_COMPILER and CMAKE_ASM_COMPILER_ID does not work either, with the same error message as before:

[1023/2055] Building ASM object _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o
FAILED: _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o 
/opt/rh/gcc-toolset-11/root/bin//gcc --defsym XXH_NAMESPACE=ZSTD_ --defsym ZSTDLIB_HIDDEN="" --defsym ZSTDLIB_VISIBLE="" -I/work/ITK-source/ITK/Modules/ThirdParty/Eigen3/src/itkeigen/.. -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/Eigen3/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/KWSys/src -I/work/oneTBB-prefix/include -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-source/ITK/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/v3p/netlib -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/vcl -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/VNL/src/vxl/core -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/Core/Common -I/work/ITK-source/ITK/Modules/Core/Common/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/IO/ImageBase -I/work/ITK-source/ITK/Modules/IO/ImageBase/include -I/work/ITK-source/ITK/Modules/IO/HDF5/include -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src -I/work/ITK-cp38-cp38-manylinux_2_28_x64/Modules/ThirdParty/ZLIB/src/itkzlib-ng -I/work/ITK-source/ITK/Modules/ThirdParty/ZLIB/src -I/work/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/include -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-build/lib -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib -O3 -DNDEBUG -fPIC -I/work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/common --MD _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o.d -o _deps/zstd-build/CMakeFiles/Zstd_zstdlib.dir/lib/decompress/huf_decompress_amd64.S.o -c /work/_skbuild/linux-x86_64-3.8/cmake-build/_deps/zstd-src/lib/decompress/huf_decompress_amd64.S
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--defsym’
gcc: error: unrecognized command-line option ‘--MD’; did you mean ‘-MD’?

I will try modifying the toolchain file next.

@dzenanz
Copy link
Author

dzenanz commented Dec 30, 2022

I tried some testing today (InsightSoftwareConsortium/ITKIOOMEZarrNGFF#13). No success so far.

@dzenanz
Copy link
Author

dzenanz commented Jan 6, 2023

Removing AS from CMake toolchain file and environment variables seems to do the trick.

@dzenanz
Copy link
Author

dzenanz commented Jan 9, 2023

@laramiel @jbms thank you both!

@dzenanz dzenanz closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants