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

Cross-compilation broken: set(Halide_TARGET "cmake") makes no sense #8531

Open
LebedevRI opened this issue Dec 20, 2024 · 7 comments
Open

Cross-compilation broken: set(Halide_TARGET "cmake") makes no sense #8531

LebedevRI opened this issue Dec 20, 2024 · 7 comments

Comments

@LebedevRI
Copy link
Contributor

LebedevRI commented Dec 20, 2024

-- Halide 'host' platform triple:   x86-64-linux
-- Halide 'cmake' platform triple:  x86-32-linux
-- Halide default AOT target:       cmake
  1/623 Test  #36: correctness_multi_gpu_gpu_multi_device .....................Subprocess aborted***Exception:   0.03 sec
Error: Did not understand Halide target cmake
Expected format is arch-bits-os-processor-feature1-feature2-...
Where arch is: arch_unknown, arm, hexagon, powerpc, riscv, wasm, x86.
bits is either 32 or 64.
os is: android, fuchsia, ios, linux, noos, os_unknown, osx, qurt, wasmrt, windows.
processor is: tune_amdfam10, tune_bdver1, tune_bdver2, tune_bdver3, tune_bdver4, tune_btver1, tune_btver2, tune_generic, tune_k8, tune_k8_sse3, tune_znver1, tune_znver2, tune_znver3, tune_znver4.

If arch, bits, or os are omitted, they default to the host.

If processor is omitted, it defaults to tune_generic.

Features are: arm_dot_prod, arm_fp16, armv7s, armv81a, armv82a, armv83a, armv84a
armv85a, armv86a, armv87a, armv88a, armv89a, armv8a, asan, avx, avx10_1
avx2, avx512, avx512_cannonlake, avx512_knl, avx512_sapphirerapids, avx512_skylake
avx512_zen4, c_plus_plus_name_mangling, check_unsafe_promises, cl_atomics64
cl_doubles, cl_half, cuda, cuda_capability_30, cuda_capability_32, cuda_capability_35
cuda_capability_50, cuda_capability_61, cuda_capability_70, cuda_capability_75
cuda_capability_80, cuda_capability_86, d3d12compute, debug, egl, embed_bitcode
enable_llvm_loop_opt, f16c, fma, fma4, fuzz_float_stores, hexagon_dma, hvx
hvx_128, hvx_v62, hvx_v65, hvx_v66, hvx_v68, jit, large_buffers, llvm_large_code_model
metal, msan, no_asserts, no_bounds_query, no_neon, no_runtime, opencl, power_arch_2_07
profile, profile_by_timer, rvv, sanitizer_coverage, semihosting, soft_float_abi
spirv, sse41, strict_float, sve, sve2, trace_loads, trace_pipeline, trace_realizations
trace_stores, tsan, user_context, vk_float16, vk_float64, vk_int16, vk_int64
vk_int8, vk_v10, vk_v12, vk_v13, vsx, vulkan, wasm_bulk_memory, wasm_mvponly
wasm_simd128, wasm_threads, webgpu, x86apx.

The target can also begin with "host", which sets the host's architecture, os, and feature set, with the exception of the GPU runtimes, which default to off.

On this platform, the host target is: x86-32-linux-tune_znver3-avx-f16c-fma-sse41

Presumably

if (NOT DEFINED Halide_TARGET)
if (NOT "$ENV{HL_TARGET}" STREQUAL "")
set(Halide_TARGET "$ENV{HL_TARGET}")
elseif (Halide_HOST_TARGET STREQUAL Halide_CMAKE_TARGET)
set(Halide_TARGET "host")
else ()
set(Halide_TARGET "cmake")
endif ()
endif ()

should be

if (NOT DEFINED Halide_TARGET)
    if (NOT "$ENV{HL_TARGET}" STREQUAL "")
        set(Halide_TARGET "$ENV{HL_TARGET}")
    elseif (Halide_HOST_TARGET STREQUAL Halide_CMAKE_TARGET)
        set(Halide_TARGET "host")
    else ()
-        set(Halide_TARGET "cmake")
+        set(Halide_TARGET "${Halide_CMAKE_TARGET}")
    endif ()
endif ()

?

@alexreinking
Copy link
Member

Hmm that should be translated from cmake later to x86-32-linux inside HalideGeneratorHelpers. Is there an easy way to repro, even if in a VM?

@LebedevRI
Copy link
Contributor Author

Uhh, i don't quite easy repro steps for you i'm afraid.

  1. clone https://salsa.debian.org/pkg-llvm-team/halide.git
  2. install git-buildpackage, sbuild
  3. configure all that magic (i don't have a howto, so it's a bit hard to do)
  4. ???
  5. run gbp buildpackage but Ctrl-C before it actually starts to build, to create tarball
  6. run sbuild --host=i386 --build=i386 and it'll repro

@alexreinking
Copy link
Member

alexreinking commented Dec 21, 2024

@LebedevRI -- I'm not sure what the following error means:

root@61223aa84e08:/ws/halide# gbp buildpackage
gbp:error: v19.0.0 is not a valid treeish

Apparently it defaults to looking for upstream/v$VERSION, but the tags are debian/$VERSION. Running this command gives the extra dependencies I have to install:

root@61223aa84e08:/ws/halide# gbp buildpackage --git-upstream-tree=debian/19.0.0-1
gbp:info: Creating halide_19.0.0.orig.tar.gz from 'debian/19.0.0-1'
gbp:info: Performing the build
 dpkg-buildpackage -us -uc -ui -i -I
dpkg-buildpackage: info: source package halide
dpkg-buildpackage: info: source version 19.0.0-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Roman Lebedev <[email protected]>
 dpkg-source -i -I --before-build .
dpkg-buildpackage: info: host architecture i386
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-32-android/libhalide_hexagon_host.so (line 31)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-64-android/libhalide_hexagon_host.so (line 576)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/host/libhalide_hexagon_host.so (line 652)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote.h (line 762)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_skel.c (line 823)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_stub.c (line 1601)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/hexagon_sim_remote (line 2513)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libhalide_hexagon_remote_skel.so (line 4667)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libsim_qurt.a (line 4841)
dpkg-checkbuilddeps: error: Unmet build dependencies: dh-python libpython3-dev pybind11-dev python3-dev python3-imageio python3-numpy clang-19 cmake doxygen libclang-19-dev libclang-rt-19-dev libflatbuffers-dev libgl-dev libjpeg-dev liblld-19-dev libomp-19-dev libopenblas-dev libpng-dev libxml2-dev lld-19 llvm-19 llvm-19-dev ninja-build zlib1g-dev
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1184:
dpkg-buildpackage -us -uc -ui -i -I failed
gbp:error: 'debuild -i -I' failed: it exited with 29

@alexreinking
Copy link
Member

alexreinking commented Dec 21, 2024

I attempted to reproduce this error in a Docker container, running on i386. Here's the Dockerfile:

FROM debian:testing
WORKDIR /ws

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get -qq -y update && \
    apt-get -y install \
      build-essential clang-19 cmake dh-python doxygen g++ git \
      git-buildpackage libclang-19-dev libclang-rt-19-dev \
      libflatbuffers-dev libgl-dev libjpeg-dev liblld-19-dev libopenblas-dev \
      libpng-dev libpython3-dev libxml2-dev lld-19 llvm-19 llvm-19-dev \
      ninja-build pybind11-dev python3-dev python3-imageio python3-numpy \
      sbuild zlib1g-dev \
      && \
    apt-get -qq -y clean && \
    rm -rf /var/lib/apt/lists/*

RUN git clone https://salsa.debian.org/pkg-llvm-team/halide.git

I built with:

$ docker buildx build --platform linux/386 -t halide-i386 --load .

Then I ran:

alex@alex-ubuntu:~$ docker run --rm -it --entrypoint linux32 halide-i386 bash
root@7d394e5ffa1a:/ws# lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux trixie/sid
Release:	n/a
Codename:	trixie
root@7d394e5ffa1a:/ws# arch
i686
root@7d394e5ffa1a:/ws# apt-get install libomp-19-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libomp-19-dev

And if I try to build without that dependency, it fails:

root@7d394e5ffa1a:/ws/halide# gbp buildpackage --git-upstream-tree=debian/19.0.0-1
gbp:info: Creating halide_19.0.0.orig.tar.gz from 'debian/19.0.0-1'
gbp:info: Performing the build
 dpkg-buildpackage -us -uc -ui -i -I
dpkg-buildpackage: info: source package halide
dpkg-buildpackage: info: source version 19.0.0-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Roman Lebedev <[email protected]>
 dpkg-source -i -I --before-build .
dpkg-buildpackage: info: host architecture i386
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-32-android/libhalide_hexagon_host.so (line 31)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-64-android/libhalide_hexagon_host.so (line 576)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/host/libhalide_hexagon_host.so (line 652)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote.h (line 762)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_skel.c (line 823)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_stub.c (line 1601)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/hexagon_sim_remote (line 2513)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libhalide_hexagon_remote_skel.so (line 4667)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libsim_qurt.a (line 4841)
dpkg-checkbuilddeps: error: Unmet build dependencies: libomp-19-dev
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1184:
dpkg-buildpackage -us -uc -ui -i -I failed
gbp:error: 'debuild -i -I' failed: it exited with 29

Same thing if I try sbuild:

root@7d394e5ffa1a:/ws/halide# sbuild --host=i386 --build=i386
The Debian buildds switched to the "unshare" backend and sbuild will default to it in the future.
To start using "unshare" add this to your `~/.config/sbuild/config.pl`:
	$chroot_mode = "unshare";
If you want to keep the old "schroot" mode even in the future, add the following to your `~/.config/sbuild/config.pl`:
	$chroot_mode = "schroot";
	$schroot = "schroot";
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-32-android/libhalide_hexagon_host.so (line 31)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/arm-64-android/libhalide_hexagon_host.so (line 576)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/host/libhalide_hexagon_host.so (line 652)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote.h (line 762)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_skel.c (line 823)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/src/halide_hexagon_remote_stub.c (line 1601)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/hexagon_sim_remote (line 2513)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libhalide_hexagon_remote_skel.so (line 4667)
dpkg-source: warning: diff halide/debian/patches/0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch removes a non-existing file halide/src/runtime/hexagon_remote/bin/v65/libsim_qurt.a (line 4841)
dpkg-buildpackage: info: source package halide
dpkg-buildpackage: info: source version 19.0.0-1
dpkg-buildpackage: info: source distribution unstable
dpkg-buildpackage: info: source changed by Roman Lebedev <[email protected]>
dpkg-checkbuilddeps: error: Unmet build dependencies: libomp-19-dev
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
E: Failed to clean source directory /ws/halide (/ws/halide_19.0.0-1.dsc)

@LebedevRI
Copy link
Contributor Author

Right, you need

diff --git a/debian/control b/debian/control
index d66c1ebf9..7a6eb4cc3 100644
--- a/debian/control
+++ b/debian/control
@@ -19,7 +19,7 @@ Build-Depends: debhelper-compat (= 13),
                libgl-dev,
                libjpeg-dev,
                liblld-19-dev,
-               libomp-19-dev,
+               libomp-19-dev [!i386],
                libopenblas-dev,
                libpng-dev,
                libxml2-dev,

@alexreinking
Copy link
Member

@LebedevRI -- I got a little further but still no luck

root@6e296dd9ef8f:/ws/halide# git show HEAD
commit 721ae8c99da3a053a0da8f709f0e270853a7a86d (HEAD -> debian)
Author: Your Name <[email protected]>
Date:   Sun Dec 22 16:44:26 2024 +0000

    patch out libomp

diff --git a/debian/control b/debian/control
index d66c1ebf9..7a6eb4cc3 100644
--- a/debian/control
+++ b/debian/control
@@ -19,7 +19,7 @@ Build-Depends: debhelper-compat (= 13),
                libgl-dev,
                libjpeg-dev,
                liblld-19-dev,
-               libomp-19-dev,
+               libomp-19-dev [!i386],
                libopenblas-dev,
                libpng-dev,
                libxml2-dev,
root@6e296dd9ef8f:/ws/halide# gbp buildpackage --git-upstream-tree=debian/19.0.0-1 
...
The next patch would delete the file src/runtime/hexagon_remote/bin/v65/libhalide_hexagon_remote_skel.so,
which does not exist!  Skipping patch.
1 out of 1 hunk ignored
The next patch would delete the file src/runtime/hexagon_remote/bin/v65/libsim_qurt.a,
which does not exist!  Skipping patch.
1 out of 1 hunk ignored
dpkg-source: info: the patch has fuzz which is not allowed, or is malformed
dpkg-source: info: if patch '0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-source: info: if the file is present in the unpacked source, make sure it is also present in the orig tarball
dpkg-buildpackage: error: dpkg-source -i -I -b . subprocess returned exit status 2
debuild: fatal error at line 1184:
dpkg-buildpackage -us -uc -ui -i -I failed
gbp:error: 'debuild -i -I' failed: it exited with 29

@LebedevRI
Copy link
Contributor Author

LebedevRI commented Dec 22, 2024

You should be fine with also applying

diff --git a/debian/patches/series b/debian/patches/series
index 9cad0106a..926648dc4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,3 @@
-0001-Remove-unrelevant-prebuild-binaries-to-pacify-lintia.patch
 0002-Fixup-libhalide-version-soversion-for-debian-package.patch
 0003-Fixup-libHalidePyStubs-version-soversion-for-debian-.patch
 0004-Disable-LTO-for-python-stub.patch

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

No branches or pull requests

2 participants