Skip to content

Using cmake's MINGW variable to detect proper ABI#579

Merged
MarkCallow merged 2 commits intoKhronosGroup:masterfrom
Honeybunch:clang-mingw
May 23, 2022
Merged

Using cmake's MINGW variable to detect proper ABI#579
MarkCallow merged 2 commits intoKhronosGroup:masterfrom
Honeybunch:clang-mingw

Conversation

@Honeybunch
Copy link
Copy Markdown
Contributor

This should make sure that any compiler that uses the mingw ABI will be using the correct .def files to link correctly

Followup to #574

Running custom action here: https://github.com/Honeybunch/KTX-Software/actions/runs/2367177228

@Honeybunch Honeybunch mentioned this pull request May 22, 2022
@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 23, 2022

My LLVM download from https://github.com/mstorsjo/llvm-mingw/releases

image

@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 23, 2022

I am not very familiar with llvm and cmake, I just know clang is child compiler project from llvm . mingw will support developing project like Linux on windows. I usually use cmake to generate makefile for mingw by useing cmake -G "MinGW Makefiles" command, after that I use mingw32-make to compiler the project.

@MarkCallow MarkCallow merged commit a70e831 into KhronosGroup:master May 23, 2022
@MarkCallow
Copy link
Copy Markdown
Collaborator

Thank you @Honeybunch for this. @FuXiii does this fix your issue?

@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 23, 2022

After I run git pull and then git log

g1018@DESKTOP-TFBV94D MINGW64 /e/Lib/KTX-Software (master)
$ git log
commit bb9babcb8aa5711410c770fea1eb29d3febf04af (HEAD -> master, origin/master, origin/HEAD)
Author: Teodor Spæren <teodor@sparen.no>
Date:   Mon May 23 11:58:51 2022 +0200

    Introduce proper vulkan initialization (#570)

    Applications can now provide an instance pointer when creating a `VulkanDeviceInfo` object.
    Optionally they can also provide pointers to the Vulkan functions to use.

    Fixes #567. Fixes #568.

commit a70e831eac91c953d31ef5381b4d66559316aa80
Author: Arsen Tufankjian <amt3824@g.rit.edu>
Date:   Sun May 22 22:55:20 2022 -0700

    Using cmake's MINGW variable to detect proper ABI (#579)

    * Using internal cmake MINGW variable to make sure that clang + mingw links properly

    * Making pthreads detection on Windows more robust
:

and then :

$ cmake . -B build -G "MinGW Makefiles" -D KTX_FEATURE_LOADTEST_APPS=ON -D KTX_FEATURE_DOC=OFF -D KTX_FEATURE_STATIC_LIBRARY=ON -D CMAKE_EXPORT_COMPILE_COMMANDS=1 -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_C_COMPILER=clang

the issue still there:

E:\Lib\KTX-Software\lib\astc_encode.cpp:437:5: error: unknown type name 'pthread_t'
    pthread_t threadHandle;
    ^
1 error generated.
mingw32-make[2]: *** [CMakeFiles\ktx.dir\build.make:521: CMakeFiles/ktx.dir/lib/astc_encode.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1191: CMakeFiles/ktx.dir/all] Error 2
mingw32-make: *** [Makefile:165: all] Error 2

〒_〒

@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 23, 2022

    if(MINGW)
            # Check if the Threads package is provided; if using Mingw it MIGHT be
            find_package(Threads)
            if(Threads_FOUND)
                target_compile_definitions(ktx PRIVATE WIN32_HAS_PTHREADS)
                target_link_libraries(ktx PRIVATE Threads::Threads)
            endif()
        endif()

the find_package(Threads), Should I download the Threads lib from some where?

@MarkCallow
Copy link
Copy Markdown
Collaborator

Did the CMake config output this time show threads were found?

I suggest that you delete the CMake cache (or the whole build directory) and start over. I've been caught out many times by values being cached from previous runs. For example, if Threads_FOUND is cached as NOTFOUND, find_package(Threads) will do nothing. If you're using the CMake GUI you can look at the cache variable values. You likely need to check Advanced to see this one.

@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 24, 2022

the cmake gui output:

Found Bash: F:/Git/bin/bash.exe  
The C compiler identification is Clang 13.0.0
The CXX compiler identification is Clang 13.0.0
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: F:/llvm-mingw-20211002-msvcrt-x86_64/bin/clang.exe - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: F:/llvm-mingw-20211002-msvcrt-x86_64/bin/clang++.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Looking for CL_VERSION_2_2
Looking for CL_VERSION_2_2 - not found
Looking for CL_VERSION_2_1
Looking for CL_VERSION_2_1 - not found
Looking for CL_VERSION_2_0
Looking for CL_VERSION_2_0 - not found
Looking for CL_VERSION_1_2
Looking for CL_VERSION_1_2 - not found
Looking for CL_VERSION_1_1
Looking for CL_VERSION_1_1 - not found
Looking for CL_VERSION_1_0
Looking for CL_VERSION_1_0 - not found
Could NOT find OpenCL (missing: OpenCL_LIBRARY OpenCL_INCLUDE_DIR) 
Found Vulkan: F:/VulkanSDK/1.3.204.1/Lib/vulkan-1.lib  
Could NOT find Perl (missing: PERL_EXECUTABLE) 
Perl not found -> skipping mkvk target (this is harmless; only needed when re-generating of vulkan headers and dfdutils is required)
Looking for pthread.h
Looking for pthread.h - found
Performing Test CMAKE_HAVE_LIBC_PTHREAD
Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
Looking for pthread_create in pthreads
Looking for pthread_create in pthreads - not found
Looking for pthread_create in pthread
Looking for pthread_create in pthread - found
Found Threads: TRUE  
  AVX2 backend     - ON
  SSE4.1 backend   - OFF
  SSE2 backend     - OFF
  NEON backend     - OFF
  NONE backend     - OFF
  NATIVE backend   - OFF
  Decompressor     - OFF
  No invariance    - OFF
  Diagnostics      - OFF
  ASAN             - OFF
  Unit tests       - OFF
Configuring done

@FuXiii
Copy link
Copy Markdown
Contributor

FuXiii commented May 24, 2022

If I use the clang/clang++ where download from https://github.com/mstorsjo/llvm-mingw/releases

F:\llvm-mingw-20220323-msvcrt-x86_64\bin>clang++.exe --version
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 329fda39c507e8740978d10458451dcdb21563be)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: F:/llvm-mingw-20220323-msvcrt-x86_64/bin

F:\llvm-mingw-20220323-msvcrt-x86_64\bin>clang.exe --version
clang version 14.0.0 (https://github.com/llvm/llvm-project.git 329fda39c507e8740978d10458451dcdb21563be)
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: F:/llvm-mingw-20220323-msvcrt-x86_64/bin

then I will get the error: unknown type name 'pthread_t'

But if I use clang/clang++ from https://github.com/llvm/llvm-project/releases

F:\LLVM\bin>clang++.exe --version
clang version 13.0.1
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: F:\LLVM\bin

F:\LLVM\bin>clang.exe --version
clang version 13.0.1
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: F:\LLVM\bin

then I will get the right finally compiled result.

Maybe the clang/clang++ under the F:\LLVM\bin use the msvc environment, and the clang/clang++ under the F:/llvm-mingw-20220323-msvcrt-x86_64/bin use the gnu environment has some different?

KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 21, 2024
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
richgel999 pushed a commit to BinomialLLC/KTX-Software-Binomial-Fork that referenced this pull request Mar 9, 2026
* Using internal cmake MINGW variable to make sure that clang + mingw links properly

* Making pthreads detection on Windows more robust
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 this pull request may close these issues.

3 participants