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

Ensure that convert_project works with compilation databases that use the command field #720

Open
mattmccutchen-cci opened this issue Oct 4, 2021 · 0 comments · May be fixed by #724
Open

Comments

@mattmccutchen-cci
Copy link
Member

convert_project currently has some logic that only works if the compilation database (compile_commands.json file) uses the arguments field rather than the command field:

# BEAR uses relative paths for 'file' rather than absolute paths. It
# also has a field called 'arguments' instead of 'command' in the cmake
# style. Use that to detect BEAR and add the directory.
if 'arguments' in i and not 'command' in i:
# BEAR. Need to add directory.
file_to_add = i['directory'] + SLASH + file_to_add
compiler_path = i['arguments'][0]
# get the compiler arguments
(compiler_x_args,
output_filename) = getCheckedCArgs(i["arguments"][1:])
# get the directory used during compilation.
target_directory = i['directory']

It seems that, knowing this, we've mostly standardized (notably, in the benchmark workflow) on using compilation databases that use arguments (as generated by Bear) rather than command (as generated by cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON), and we haven't made much of an effort to address the command case in recent changes to convert_project. (To be clear, that "we" is mostly me.) I did a simple test with cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON, and the 3C run seemed to work, but the macro expander didn't work at all.

Ideally, all of our tools should support all important features of the Clang compilation database specification. command is the main feature we are missing; output might also be worth considering where it is relevant (e.g., for the macro expander). We can start with convert_project. Some of our utils-5c tools may also need work, notably compdb build; we can file a separate issue in the utils-5c repository if we want.

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

Successfully merging a pull request may close this issue.

1 participant