mstorsjo/msvc-wine

libtiff not building with clang-cl

Closed this issue · 7 comments

I'm not able to get libtiff building using the clang-cl utility.

: && /usr/bin/cmake -E vs_link_exe --intdir=contrib/iptcutil/CMakeFiles/iptcutil.dir --rc=/usr/lib/llvm/17/bin/llvm-rc --mt=CMAKE_MT-NOTFOUND --manifests  -- /usr/lib/llvm/17/bin/lld-link /nologo contrib/iptcutil/CMakeFiles/iptcutil.dir/iptcutil.c.obj  /out:contrib/iptcutil/iptcutil.exe /implib:contrib/iptcutil/iptcutil.lib /pdb:contrib/iptcutil/iptcutil.pdb /version:0.0 /MANIFEST:NO /INCREMENTAL:NO /subsystem:console  libtiff/tiff.lib  port/tiff_port.lib  /data/modix/modixslicer/deps/build-msvc-clang/destdir/usr/local/lib/zlib.lib  /data/modix/modixslicer/deps/build-msvc-clang/destdir/usr/local/lib/jpeg-static.lib  /usr/lib/libm.a  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
LINK: command "/usr/lib/llvm/17/bin/lld-link /nologo contrib/iptcutil/CMakeFiles/iptcutil.dir/iptcutil.c.obj /out:contrib/iptcutil/iptcutil.exe /implib:contrib/iptcutil/iptcutil.lib /pdb:contrib/iptcutil/iptcutil.pdb /version:0.0 /MANIFEST:NO /INCREMENTAL:NO /subsystem:console libtiff/tiff.lib port/tiff_port.lib /data/modix/modixslicer/deps/build-msvc-clang/destdir/usr/local/lib/zlib.lib /data/modix/modixslicer/deps/build-msvc-clang/destdir/usr/local/lib/jpeg-static.lib /usr/lib/libm.a kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" failed (exit code 1) with the following output:
lld-link: error: unknown file type: fegetround.o
lld-link: error: unknown file type: fegetenv.o
lld-link: error: unknown file type: fesetenv.o
lld-link: error: unknown file type: feholdexcpt.o
lld-link: error: unknown file type: s_ceil.o
lld-link: error: unknown file type: w_log10.o

It's doing the file not found stuff again. I have no idea what is going on with this.

-- The C compiler identification is Clang 15.0.7 with MSVC-like command-line
-- The CXX compiler identification is Clang 15.0.7 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/lib/llvm/15/bin/clang-cl
-- Check for working C compiler: /usr/lib/llvm/15/bin/clang-cl - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/lib/llvm/15/bin/clang-cl"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/data/modix/modixslicer/deps/build-msvc-clang/CMakeFiles/CMakeScratch/TryCompile-xLjLuZ'
    
    Run Build Command(s): /usr/bin/ninja -v cmTC_712fd
    [1/2] /usr/lib/llvm/15/bin/clang-cl  /nologo   --target=x86_64-windows-msvc  /Ob0 /Od /RTC1 -MDd -Z7 /showIncludes /FoCMakeFiles/cmTC_712fd.dir/testCCompiler.c.obj /FdCMakeFiles/cmTC_712fd.dir/ -c -- /data/modix/modixslicer/deps/build-msvc-clang/CMakeFiles/CMakeScratch/TryCompile-xLjLuZ/testCCompiler.c
    [2/2] : && /usr/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_712fd.dir --rc=/usr/lib/llvm/15/bin/llvm-rc --mt=/usr/lib/llvm/15/bin/llvm-mt --manifests  -- /usr/lib/llvm/15/bin/llvm-link /nologo CMakeFiles/cmTC_712fd.dir/testCCompiler.c.obj  /out:cmTC_712fd.exe /implib:cmTC_712fd.lib /pdb:cmTC_712fd.pdb /version:0.0 /MANIFEST:NO  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    FAILED: cmTC_712fd.exe 
    : && /usr/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_712fd.dir --rc=/usr/lib/llvm/15/bin/llvm-rc --mt=/usr/lib/llvm/15/bin/llvm-mt --manifests  -- /usr/lib/llvm/15/bin/llvm-link /nologo CMakeFiles/cmTC_712fd.dir/testCCompiler.c.obj  /out:cmTC_712fd.exe /implib:cmTC_712fd.lib /pdb:cmTC_712fd.pdb /version:0.0 /MANIFEST:NO  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && :
    LINK: command "/usr/lib/llvm/15/bin/llvm-link /nologo CMakeFiles/cmTC_712fd.dir/testCCompiler.c.obj /out:cmTC_712fd.exe /implib:cmTC_712fd.lib /pdb:cmTC_712fd.pdb /version:0.0 /MANIFEST:NO /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" failed (exit code 1) with the following output:
    /usr/lib/llvm/15/bin/llvm-link: No such file or directory
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:27 (project)


-- Configuring incomplete, errors occurred!
phil@gentoo /data/modix/modixslicer/deps $ /usr/lib/llvm/15/bin/llvm-link --version
LLVM (http://llvm.org/):
  LLVM version 15.0.7
  Optimized build.
  Default target: x86_64-pc-linux-gnu
  Host CPU: znver3

What is invoking llvm-link? Are you accidentally passing the wrong executable name somewhere? The binary llvm-link is never used in such a setting, it's called lld-link.

Oh right, I wasn't aware these are two different things. Now the error is back to the first one, with the unknown file types.

Maybe my clang needs to be compiled with support for the PE stuff? How would I check this?

One can't omit support for individual object file formats in Clang (only individual architectures), and if you have a distribution provided binary, it most probably has all enabled.

The error from lld-link means that the object file wasn't actually a COFF object file. What does file fegetenv.o say?

From your posted command line, you're linking to /usr/lib/libm.a which is definitely obviously wrong.

Ah I see, the issues is that libtiff is trying to link examples, but that won't be working when building the static library.
So disabling that and the build works.