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

Xmake generates invalid compilation database #3159

Closed
poscat0x04 opened this issue Dec 10, 2022 · 9 comments
Closed

Xmake generates invalid compilation database #3159

poscat0x04 opened this issue Dec 10, 2022 · 9 comments
Labels
Milestone

Comments

@poscat0x04
Copy link

Xmake Version

v2.7.3+202211090100

Operating System Version and Architecture

macOS Monterey

Describe Bug

When being used to compile 墨干 on macOS, xmake generates invalid compilation database files:

[
{
  "directory": "/Users/poscat/Projects/mogan",
  "arguments": ["/usr/bin/xcrun -sdk macosx clang", "-c", "-Qunused-arguments", "-target", "arm64-apple-macos12.6", "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk", "-g", "-O0", "-std=c++17", "-Itests/Base", "-I/Users/poscat/Projects/mogan/build/.gens/url_test/macosx/arm64/debug/rules/qt/ui", "-Isrc/Data/Convert", "-Isrc/Data/Document", "-Isrc/Data/Drd", "-Isrc/Data/History", "-Isrc/Data/Observers", "-Isrc/Data/Parser", "-Isrc/Data/String", "-Isrc/Data/Tree", "-Isrc/Edit", "-Isrc/Edit/Editor", "-Isrc/Edit/Interface", "-Isrc/Edit/Modify", "-Isrc/Edit/Process", "-Isrc/Edit/Replace", "-Isrc/Graphics/Bitmap_fonts", "-Isrc/Graphics/Colors", "-Isrc/Graphics/Fonts", "-Isrc/Graphics/Gui", "-Isrc/Graphics/Handwriting", "-Isrc/Graphics/Mathematics", "-Isrc/Graphics/Pictures", "-Isrc/Graphics/Renderer", "-Isrc/Graphics/Spacial", "-Isrc/Graphics/Types", "-Isrc/Kernel/Abstractions", "-Isrc/Kernel/Containers", "-Isrc/Kernel/Types", "-Isrc/Plugins", "-Isrc/Plugins/Pdf", "-Isrc/Plugins/Pdf/PDFWriter", "-Isrc/Plugins/Pdf/LibAesgm", "-Isrc/Plugins/Qt", "-Isrc/Plugins/UniversalStacktrace", "-Isrc/Scheme", "-Isrc/Scheme/S7", "-Isrc/Scheme/Scheme", "-Isrc/Style/Environment", "-Isrc/Style/Evaluate", "-Isrc/Style/Memorizer", "-Isrc/System", "-Isrc/System/Memory", "-Isrc/System/IO", "-Isrc/System/Boot", "-Isrc/System/Classes", "-Isrc/System/Files", "-Isrc/System/Language", "-Isrc/System/Link", "-Isrc/System/Misc", "-Isrc/Texmacs", "-Isrc/Texmacs/Data", "-Isrc/Typeset", "-Isrc/Typeset/Bridge", "-Isrc/Typeset/Concat", "-Isrc/Typeset/Page", "-ITeXmacs/include", "-Isrc/Plugins/MacOS", "-DQTTEXMACS", "-DQTPIPES", "-DUSE_QT_PRINTER", "-DQT_QML_DEBUG", "-DQT_DEPRECATED_WARNINGS", "-DQT_GUI_LIB", "-DQT_WIDGETS_LIB", "-DQT_PRINTSUPPORT_LIB", "-DQT_SVG_LIB", "-DQT_TEST_LIB", "-DQT_CORE_LIB", "-F/opt/homebrew/Cellar/qt@5/5.15.7/lib", "-framework", "QtTest", "-framework", "DiskArbitration", "-framework", "IOKit", "-framework", "CoreGraphics", "-framework", "OpenGL", "-framework", "Carbon", "-framework", "AppKit", "-framework", "QtGui", "-framework", "QtWidgets", "-framework", "QtPrintSupport", "-framework", "QtSvg", "-framework", "QtMacExtras", "-framework", "QtCore", "-framework", "CoreFoundation", "-framework", "Foundation", "-framework", "Security", "-framework", "SystemConfiguration", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtGui.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtGui.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtGui.framework/Headers/5.15.7/QtGui", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtWidgets.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtWidgets.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtWidgets.framework/Headers/5.15.7/QtWidgets", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtPrintSupport.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtPrintSupport.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtPrintSupport.framework/Headers/5.15.7/QtPrintSupport", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtSvg.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtSvg.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtSvg.framework/Headers/5.15.7/QtSvg", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtTest.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtTest.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtTest.framework/Headers/5.15.7/QtTest", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtCore.framework/Headers", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtCore.framework/Headers/5.15.7", "-I", "/opt/homebrew/Cellar/qt@5/5.15.7/lib/QtCore.framework/Headers/5.15.7/QtCore", "-fPIC", "-o", "build/.objs/url_test/macosx/arm64/debug/tests/Base/base.cpp.o", "tests/Base/base.cpp"],
  "file": "tests/Base/base.cpp"
},
... (omitted)

(full file)

As you can see, the first argument, "/usr/bin/xcrun -sdk macosx clang" is invalid as it does not point to an executable and should be broken up into four arguments instead.

Expected Behavior

The generated compilation database file should be valid

Project Configuration

No response

Additional Information and Error Logs

To reproduce, just clone mogan and run xmake project -k compile_commands

@poscat0x04 poscat0x04 added the bug label Dec 10, 2022
@waruqi
Copy link
Member

waruqi commented Dec 10, 2022

As you can see, the first argument, "/usr/bin/xcrun -sdk macosx clang" is invalid as it does not point to an executable and should be broken up into four arguments instead.

no, it's valid and it works for me. It has been around for a long time and no other user has ever reported an error because of it.

@poscat0x04
Copy link
Author

poscat0x04 commented Dec 10, 2022

According to the spec of compilation database, the first argument should be the executable name. This is also how CLion interprets it, which leads to errors when using CLion.

@waruqi
Copy link
Member

waruqi commented Dec 12, 2022

which leads to errors when using CLion.

which errors? it works for vscode on my machine and I cannot get any errors in CLion.

@poscat0x04
Copy link
Author

CLion complains about not being able to find "/usr/bin/xcrun -sdk macosx clang" in path (which I think is 100% justified)

@waruqi
Copy link
Member

waruqi commented Dec 14, 2022

I can't reproduce the problem at the moment, so you can verify that it works by manually changing it to something like the following.

  "arguments": ["/usr/bin/xcrun", "-sdk", "macosx", "clang", "-c", "-Qunused-arguments", "-target", "arm64-apple-macos12.6", ...

If this works, I will try to improve it.

@poscat0x04
Copy link
Author

Yes, breaking up the first argument does work.

waruqi added a commit that referenced this issue Dec 17, 2022
@waruqi waruqi added this to the v2.7.4 milestone Dec 17, 2022
@waruqi
Copy link
Member

waruqi commented Dec 17, 2022

try it again, xmake update -s dev

@waruqi
Copy link
Member

waruqi commented Jan 13, 2023

but clangd does not support ["/usr/bin/xcrun", "-sdk", "macosx", "clang"

#3286

@waruqi
Copy link
Member

waruqi commented Jan 21, 2023

I improved it again, it will convert to "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"

xmake update -s dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants