Improve clangd support #8867
3 changed files with 9 additions and 0 deletions
4
.clangd
Normal file
4
.clangd
Normal file
|
@ -0,0 +1,4 @@
|
|||
CompileFlags:
|
||||
Remove:
|
||||
# clang has an issue with this flag, while gcc does not
|
||||
- "-mno-direct-extern-access"
|
||||
![]() This flag appears in the CMake-generated This flag appears in the CMake-generated `build.ninja` files. Can you confirm if it appears in yours?
Indeed, I'm not sure where it comes from...
![]() It looks like some dependency sets it. Can you try to trace cmake with debug/verbose/trace mode? It looks like some dependency sets it. Can you try to trace cmake with debug/verbose/trace mode?
![]() According to gcc's man page:
It's rather weird because I'm clearly using GCC to compile OM, yet CMake adds that flag, which is already the default. Seems like the issue stems from clang having a different name for this: According to gcc's man page:
```
-mdirect-extern-access
-mno-direct-extern-access
Do not use or use GOT to access external symbols. The default is -mno-direct-extern-access: GOT is used for external symbols with default visibility, but not used for other
external symbols.
With -mdirect-extern-access, GOT is not used and all external symbols are PC-relatively addressed. It is only suitable for environments where no dynamic link is performed, like
firmwares, OS kernels, executables linked with -static or -static-pie. -mdirect-extern-access is not compatible with -fPIC or -fpic.
```
It's rather weird because I'm clearly using GCC to compile OM, yet CMake adds that flag, which is already the default.
Seems like the issue stems from clang having a different name for this: [`-fdirect-access-external-data`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fdirect-access-external-data).
![]()
Looks like it's a Qt6 thing:
> It looks like some dependency sets it. Can you try to trace cmake with debug/verbose/trace mode?
Looks like it's a Qt6 thing:
```
Called from: [3] /usr/lib/cmake/Qt6/Qt6Targets.cmake
[2] /usr/lib/cmake/Qt6/Qt6Config.cmake
[1] /home/tmpod/Programming/GSoC/2024/organicmaps/CMakeLists.txt
/usr/lib/cmake/Qt6/Qt6Targets.cmake(70): set_target_properties(Qt6::Platform PROPERTIES INTERFACE_COMPILE_FEATURES cxx_std_17 INTERFACE_COMPILE_OPTIONS \$<\$<CXX_COMPILER_ID:GNU>:-mno-direct-extern-access>;\$<\$<CXX_COMPILER_ID:Clang>:-fno-direct-access-external-data> INTERFACE_INCLUDE_DIRECTORIES ${_IMPORT_PREFIX}/lib/qt6/mkspecs/linux-g++;${_IMPORT_PREFIX}/include/qt6 INTERFACE_LINK_LIBRARIES Threads::Threads _qt_package_version 6.7.2 )
```
![]() @biodranik What is your Qt6 version? @biodranik What is your Qt6 version?
![]() 6.6 on Mac 6.6 on Mac
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -188,3 +188,6 @@ screenshots/
|
|||
android/src/google/play/listings/
|
||||
keywords/
|
||||
iphone/metadata/**/keywords.txt
|
||||
|
||||
# clangd cache
|
||||
.cache/clangd/
|
||||
|
|
|
@ -11,6 +11,8 @@ set(CMAKE_C_VISIBILITY_PRESET hidden)
|
|||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Fixes warning ld: warning: ignoring duplicate libraries on Mac and Windows.
|
||||
if (POLICY CMP0156)
|
||||
cmake_policy(SET CMP0156 NEW)
|
||||
|
|
Reference in a new issue
It would be great to know where does this flag come from :) Is it your system-specific issue?