Support Clang LSP development on CRuby - #6352
Closed
tenderlove wants to merge 1 commit into
Closed
Conversation
tenderlove
force-pushed
the
clangd-support
branch
2 times, most recently
from
September 10, 2022 02:51
5cb4304 to
d5475d4
Compare
nobu
reviewed
Sep 10, 2022
Member
|
I like this. |
tenderlove
force-pushed
the
clangd-support
branch
from
September 10, 2022 20:18
d5475d4 to
3a56bf0
Compare
Member
Author
|
@nobu thanks for the feedback. I don't know autotools / Make very well, so I just did my best to get this working. I think if developers enable |
nobu
reviewed
Sep 11, 2022
nobu
reviewed
Sep 11, 2022
nobu
reviewed
Sep 11, 2022
This commit adds a new configure flag `--enable-compile-commands`. The flag enables building a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) while building CRuby. This option is intended for people who are doing development work on CRuby using Clang, and is *not* meant for use when doing normal builds of CRuby. Enabling this flag will add `-MJ [email protected]` to the compilation flags. The [`MJ` flag](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mj-arg) takes a file argument, and writes a compilation database entry unit to that file. For example: ``` $ make gc.o making gc.rbinc generating id.h id.h updated /usr/bin/ruby --disable=gems ./tool/gen_dummy_probes.rb ./probes.d > probes.dmyh translating probes probes.d . ./vm_opts.h compiling gc.c $ cat gc.o.json { "directory": "/Users/aaron/git/ruby", "file": "gc.c", "output": "gc.o", "arguments": ["/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang", "-xc", "gc.c", "-fdeclspec", "-O3", "-fno-fast-math", "-ggdb3", "-Wall", "-Wextra", "-Wextra-tokens", "-Wdeprecated-declarations", "-Wdivision-by-zero", "-Wdiv-by-zero", "-Wimplicit-function-declaration", "-Wimplicit-int", "-Wmisleading-indentation", "-Wpointer-arith", "-Wshorten-64-to-32", "-Wwrite-strings", "-Wold-style-definition", "-Wmissing-noreturn", "-Wno-cast-function-type", "-Wno-constant-logical-operand", "-Wno-long-long", "-Wno-missing-field-initializers", "-Wno-overlength-strings", "-Wno-parentheses-equality", "-Wno-self-assign", "-Wno-tautological-compare", "-Wno-unused-parameter", "-Wno-unused-value", "-Wunused-variable", "-Wundef", "-std=gnu99", "-pipe", "-D", "_FORTIFY_SOURCE=2", "-fstack-protector-strong", "-fno-strict-overflow", "-fvisibility=hidden", "-D", "RUBY_EXPORT", "-fPIE", "-I", ".", "-I", ".ext/include/arm64-darwin21", "-I", "./include", "-I", ".", "-I", "./enc/unicode/14.0.0", "-D", "_XOPEN_SOURCE", "-D", "_DARWIN_C_SOURCE", "-D", "_DARWIN_UNLIMITED_SELECT", "-D", "_REENTRANT", "-o", "gc.o", "-c", "-Wno-reorder-init-list", "-Wno-implicit-int-float-conversion", "-Wno-c99-designator", "-Wno-final-dtor-non-final-class", "-Wno-extra-semi-stmt", "-Wno-quoted-include-in-framework-header", "-Wno-implicit-fallthrough", "-Wno-enum-enum-conversion", "-Wno-enum-float-conversion", "-Wno-elaborated-enum-base", "-Wno-reserved-identifier", "-Wno-gnu-folding-constant", "-Wno-objc-load-method", "-Xclang", "-clang-vendor-feature=+messageToSelfInClassMethodIdReturnType", "-Xclang", "-clang-vendor-feature=+disableInferNewAvailabilityFromInit", "-Xclang", "-clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation", "-mllvm", "-disable-aligned-alloc-awareness=1", "-Xclang", "-fno-odr-hash-protocols", "-Xclang", "-clang-vendor-feature=+enableAggressiveVLAFolding", "-Xclang", "-clang-vendor-feature=+revert09abecef7bbf", "-Xclang", "-clang-vendor-feature=+thisNoAlignAttr", "-Xclang", "-clang-vendor-feature=+thisNoNullAttr", "-mlinker-version=763", "-isysroot", "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk", "-mmacosx-version-min=12.0.0", "-stdlib=libc++", "--target=arm64-apple-macosx12.0.0"]}, ``` `clangd` [looks for a file called `compile_commands.json`](https://clangd.llvm.org/installation.html#compile_commandsjson), and doing `make compile_commands.json` will generate that file.
tenderlove
force-pushed
the
clangd-support
branch
from
September 14, 2022 22:39
abb1a27 to
ef985a8
Compare
Member
|
@tenderlove what was the status of this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit adds a new configure flag
--enable-compile-commands. The flag enables building a compilationdatabase while building CRuby. This option is intended for people who are doing development work on CRuby using Clang, and is not meant for use when doing normal builds of CRuby.
Enabling this flag will add
-MJ [email protected]to the compilation flags. TheMJflag takes a file argument, and writes a compilation database entry unit to that file. For example:
clangdlooks for a file calledcompile_commands.json, and doingmake compile_commands.jsonwill generate that file.Summary
This PR adds: