[clang] [Windows] error: unsupported option '-fPIC'
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- c, cmake
- Ambito
- build-system
Direzione di ricerca
Inizia con il workflow GitHub Actions fornito e ispeziona il comando del compilatore generato da CMake per deps/llhttp/http.c e deps/pcre/pcre_byte_order.c. Traccia il punto in cui viene aggiunto -fPIC per la configurazione Clang su Windows, quindi verifica che la configurazione di CMake e la compilazione vengano completate correttamente con clang.exe su Windows.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Tested on the latest commit (3ac4c0adb1064bad16a7f980d87e7261753fd07e).
Trying to build libgit2 using clang (not clang-cl) on Windows fails with the following error:
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
You can replicate the issue with the following github workflow:
name: Build libgit2 with Clang (Windows)
on:
push:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: bash
steps:
- name: Checkout libgit2
uses: actions/checkout@v4
with:
repository: libgit2/libgit2
path: libgit2
- name: Download and Extract LLVM
run: |
echo "Downloading LLVM..."
curl -L -o llvm.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.8/clang+llvm-21.1.8-x86_64-pc-windows-msvc.tar.xz
echo "Extracting LLVM..."
mkdir -p llvm_install
# -C changes to the directory, --strip-components-1 removes the top-level folder from the archive
tar -xf llvm.tar.xz -C llvm_install --strip-components=1
# Add Clang to the path for this session
echo "$(pwd)/llvm_install/bin" >> $GITHUB_PATH
- name: Configure and Build libgit2
run: |
cd libgit2
mkdir build && cd build
cmake .. \
-G "Ninja" \
-DCMAKE_C_COMPILER="$(pwd)/../../llvm_install/bin/clang.exe" \
-DCMAKE_CXX_COMPILER="$(pwd)/../../llvm_install/bin/clang++.exe" \
-DCMAKE_BUILD_TYPE=Release
cmake --build .
See https://github.com/Silverlan/test_libgit2/blob/main/.github/workflows/windows-clang-libgit2.yml
Full log:
CMake Deprecation Warning at CMakeLists.txt:7 (cmake_minimum_required):
Compatibility with CMake < 3.10 will be removed from a future version of
CMake.
Update the VERSION argument <min> value. Or, use the <min>...<max> syntax
to tell CMake that the project requires at least <min> but has been updated
to work with policies introduced by <max> or earlier.
-- The C compiler identification is Clang 21.1.8 with GNU-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: D:/a/test_libgit2/test_libgit2/llvm_install/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- 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 - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - no
-- Found Threads: TRUE
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM
-- Performing Test HAVE_STRUCT_STAT_ST_MTIM - Failed
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC
-- Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC - Failed
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC
-- Performing Test HAVE_STRUCT_STAT_MTIME_NSEC - Failed
-- Looking for futimens
-- Looking for futimens - not found
-- Performing Test IS_WALL_SUPPORTED
-- Performing Test IS_WALL_SUPPORTED - Success
-- Performing Test IS_WEXTRA_SUPPORTED
-- Performing Test IS_WEXTRA_SUPPORTED - Success
-- Performing Test IS_FVISIBILITY_HIDDEN_SUPPORTED
-- Performing Test IS_FVISIBILITY_HIDDEN_SUPPORTED - Success
-- Performing Test IS_WDOCUMENTATION_SUPPORTED
-- Performing Test IS_WDOCUMENTATION_SUPPORTED - Failed
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED
-- Performing Test IS_WNO_DOCUMENTATION_DEPRECATED_SYNC_SUPPORTED - Failed
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED
-- Performing Test IS_WNO_MISSING_FIELD_INITIALIZERS_SUPPORTED - Failed
-- Performing Test IS_WMISSING_DECLARATIONS_SUPPORTED
-- Performing Test IS_WMISSING_DECLARATIONS_SUPPORTED - Failed
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED
-- Performing Test IS_WSTRICT_ALIASING_SUPPORTED - Failed
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED
-- Performing Test IS_WSTRICT_PROTOTYPES_SUPPORTED - Failed
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED
-- Performing Test IS_WDECLARATION_AFTER_STATEMENT_SUPPORTED - Failed
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED
-- Performing Test IS_WSHIFT_COUNT_OVERFLOW_SUPPORTED - Failed
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED
-- Performing Test IS_WUNUSED_CONST_VARIABLE_SUPPORTED - Failed
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED
-- Performing Test IS_WUNUSED_FUNCTION_SUPPORTED - Failed
-- Performing Test IS_WINT_CONVERSION_SUPPORTED
-- Performing Test IS_WINT_CONVERSION_SUPPORTED - Failed
-- Performing Test IS_WC11_EXTENSIONS_SUPPORTED
-- Performing Test IS_WC11_EXTENSIONS_SUPPORTED - Failed
-- Performing Test IS_WC99_C11_COMPAT_SUPPORTED
-- Performing Test IS_WC99_C11_COMPAT_SUPPORTED - Failed
-- Performing Test IS_WFORMAT_SUPPORTED
-- Performing Test IS_WFORMAT_SUPPORTED - Failed
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED
-- Performing Test IS_WFORMAT_SECURITY_SUPPORTED - Failed
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
-- Could NOT find PCRE (missing: PCRE_LIBRARY PCRE_INCLUDE_DIR)
-- Looking for regcomp_l
-- Looking for regcomp_l - not found
-- Looking for dirent.h
-- Looking for dirent.h - not found
-- Looking for stdint.h
-- Looking for stdint.h - not found
-- Looking for inttypes.h
-- Looking for inttypes.h - not found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - not found
-- Looking for windows.h
-- Looking for windows.h - not found
-- Looking for bcopy
-- Looking for bcopy - not found
-- Looking for memmove
-- Looking for memmove - not found
-- Looking for strerror
-- Looking for strerror - not found
-- Looking for strtoll
-- Looking for strtoll - not found
-- Looking for strtoq
-- Looking for strtoq - not found
-- Looking for _strtoi64
-- Looking for _strtoi64 - not found
-- Looking for stddef.h
-- Looking for stddef.h - not found
-- Check size of long long
-- Check size of long long - failed
-- Check size of unsigned long long
-- Check size of unsigned long long - failed
-- Performing Test IS_WNO_UNUSED_FUNCTION_SUPPORTED
-- Performing Test IS_WNO_UNUSED_FUNCTION_SUPPORTED - Failed
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED
-- Performing Test IS_WNO_IMPLICIT_FALLTHROUGH_SUPPORTED - Failed
-- Performing Test IS_WNO_UNUSED_BUT_SET_VARIABLE_SUPPORTED
-- Performing Test IS_WNO_UNUSED_BUT_SET_VARIABLE_SUPPORTED - Failed
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- zlib was not found; using bundled 3rd-party sources.
-- Looking for iconv_open
-- Looking for iconv_open - not found
-- Could NOT find GSSAPI (missing: GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
-- Performing Test IS_WNO_UNUSED_PARAMETER_SUPPORTED
-- Performing Test IS_WNO_UNUSED_PARAMETER_SUPPORTED - Failed
-- Checking prototype qsort_r for GIT_QSORT_BSD
-- Checking prototype qsort_r for GIT_QSORT_BSD - False
-- Checking prototype qsort_r for GIT_QSORT_GNU
-- Checking prototype qsort_r for GIT_QSORT_GNU - False
-- Checking prototype qsort_s for GIT_QSORT_C11
-- Checking prototype qsort_s for GIT_QSORT_C11 - False
-- Checking prototype qsort_s for GIT_QSORT_MSC
-- Checking prototype qsort_s for GIT_QSORT_MSC - False
-- Looking for getentropy
-- Looking for getentropy - not found
-- Looking for getloadavg
-- Looking for getloadavg - not found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Found PythonInterp: C:/hostedtoolcache/windows/Python/3.9.13/x64/python3.exe (found version "3.9.13")
-- Enabled features:
* Threads, using pthreads
* Nanosecond support, using Win32 APIs
* HTTPS, using WinHTTP
* SHA1, using bundled collision detection implementation
* SHA256, using Win32 APIs
* HTTP Parser, using bundled parser
* Regular expressions, using bundled implementation
* Xdiff, using bundled provider
* Compression, using bundled zlib
* NTLM authentication, using Win32 SSPI
* Negotiate authentication, using Win32 SSPI
-- Disabled features:
* SHA256 API, experimental SHA256 APIs
* Debug pool, debug-mode struct pool allocators
* Debug alloc, debug-mode strict allocators
* Debug open, strict path validation in open
* SSH, SSH transport support
* Internationalization, internationalization support is disabled
-- Configuring done (19.2s)
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_CXX_COMPILER
-- Generating done (0.4s)
-- Build files have been written to: D:/a/test_libgit2/test_libgit2/libgit2/build
[1/711] Building C object deps/llhttp/CMakeFiles/llhttp.dir/http.c.obj
FAILED: [code=1] deps/llhttp/CMakeFiles/llhttp.dir/http.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DWIN32 -D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -Wno-unused-parameter -Wno-missing-declarations -MD -MT deps/llhttp/CMakeFiles/llhttp.dir/http.c.obj -MF deps\llhttp\CMakeFiles\llhttp.dir\http.c.obj.d -o deps/llhttp/CMakeFiles/llhttp.dir/http.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/llhttp/http.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[2/711] Building C object deps/llhttp/CMakeFiles/llhttp.dir/llhttp.c.obj
FAILED: [code=1] deps/llhttp/CMakeFiles/llhttp.dir/llhttp.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DWIN32 -D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -Wno-unused-parameter -Wno-missing-declarations -MD -MT deps/llhttp/CMakeFiles/llhttp.dir/llhttp.c.obj -MF deps\llhttp\CMakeFiles\llhttp.dir\llhttp.c.obj.d -o deps/llhttp/CMakeFiles/llhttp.dir/llhttp.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/llhttp/llhttp.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[3/711] Building C object deps/llhttp/CMakeFiles/llhttp.dir/api.c.obj
FAILED: [code=1] deps/llhttp/CMakeFiles/llhttp.dir/api.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DWIN32 -D_WIN32_WINNT=0x0600 -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -Wno-unused-parameter -Wno-missing-declarations -MD -MT deps/llhttp/CMakeFiles/llhttp.dir/api.c.obj -MF deps\llhttp\CMakeFiles\llhttp.dir\api.c.obj.d -o deps/llhttp/CMakeFiles/llhttp.dir/api.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/llhttp/api.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[4/711] Building C object deps/pcre/CMakeFiles/pcre.dir/pcre_byte_order.c.obj
FAILED: [code=1] deps/pcre/CMakeFiles/pcre.dir/pcre_byte_order.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DHAVE_CONFIG_H -DWIN32 -D_WIN32_WINNT=0x0600 -ID:/a/test_libgit2/test_libgit2/libgit2/build/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/build/src/pcre -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -MD -MT deps/pcre/CMakeFiles/pcre.dir/pcre_byte_order.c.obj -MF deps\pcre\CMakeFiles\pcre.dir\pcre_byte_order.c.obj.d -o deps/pcre/CMakeFiles/pcre.dir/pcre_byte_order.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/pcre/pcre_byte_order.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[5/711] Building C object deps/pcre/CMakeFiles/pcre.dir/pcre_chartables.c.obj
FAILED: [code=1] deps/pcre/CMakeFiles/pcre.dir/pcre_chartables.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DHAVE_CONFIG_H -DWIN32 -D_WIN32_WINNT=0x0600 -ID:/a/test_libgit2/test_libgit2/libgit2/build/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/build/src/pcre -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -MD -MT deps/pcre/CMakeFiles/pcre.dir/pcre_chartables.c.obj -MF deps\pcre\CMakeFiles\pcre.dir\pcre_chartables.c.obj.d -o deps/pcre/CMakeFiles/pcre.dir/pcre_chartables.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/pcre/pcre_chartables.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
[6/711] Building C object deps/pcre/CMakeFiles/pcre.dir/pcre_compile.c.obj
FAILED: [code=1] deps/pcre/CMakeFiles/pcre.dir/pcre_compile.c.obj
D:\a\test_libgit2\test_libgit2\llvm_install\bin\clang.exe -DHAVE_CONFIG_H -DWIN32 -D_WIN32_WINNT=0x0600 -ID:/a/test_libgit2/test_libgit2/libgit2/build/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/deps/pcre -ID:/a/test_libgit2/test_libgit2/libgit2/build/src/pcre -D_GNU_SOURCE -Wall -Wextra -fvisibility=hidden -fPIC -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=c90 -MD -MT deps/pcre/CMakeFiles/pcre.dir/pcre_compile.c.obj -MF deps\pcre\CMakeFiles\pcre.dir\pcre_compile.c.obj.d -o deps/pcre/CMakeFiles/pcre.dir/pcre_compile.c.obj -c D:/a/test_libgit2/test_libgit2/libgit2/deps/pcre/pcre_compile.c
clang: error: unsupported option '-fPIC' for target 'x86_64-pc-windows-msvc'
ninja: build stopped: subcommand failed.
Error: Process completed with exit code 1.
Ideally the use of -fPIC in the CMake scripts should probably be replaced with POSITION_INDEPENDENT_CODE.
As far as I know -fPIC doesn't have any effect on Windows anyway though, so the easiest solution would be to just wrap the -fPIC option with if(WIN32) (except when cross-compiling).
The problematic code in libgit2 is located here:
https://github.com/libgit2/libgit2/blob/3ac4c0adb1064bad16a7f980d87e7261753fd07e/cmake/DefaultCFlags.cmake#L113-L119
- Lingua principale
- C
- Stelle
- 10.6k
- Fork
- 2.7k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di libgit2/libgit2
-
hashsig: the similarity heap evicts but never inserts, so the retained set is not the extremes Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
Tutte le issue di libgit2/libgit2
Issue simili
-
task
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vsanthanam/JBird#429 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
es-ude/OnDeviceTraining#459 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
bilelmoussaoui/gobject-linter#199 · 1 commento ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
bradcypert/plum#53 ·