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

compile_flags plugin is too selective when filtering flags #5272

Open
MinekPo1 opened this issue Jun 28, 2024 · 4 comments
Open

compile_flags plugin is too selective when filtering flags #5272

MinekPo1 opened this issue Jun 28, 2024 · 4 comments
Labels

Comments

@MinekPo1
Copy link

MinekPo1 commented Jun 28, 2024

Xmake Version

v2.9.3 HEAD.a5da06f

Operating System Version and Architecture

GNU/Linux 6.8.0-35-generic Ubuntu KDE Plasma

Describe Bug

the compile_flags plugin is too selective when filtering through flags resulting in important flags being excluded

Expected Behavior

All flags which control C or C (gcc's list, clang's documentation including flags but not in a nice list like gcc unfortunately, msvc's list) are included in the compile_flags.txt file.

Actual Behavior

Only flags beginning with -I, /I, -isystem or -D are included.

Project Configuration

add_cxxflags("-std=c  23")

Additional Information and Error Logs

N/A

@MinekPo1 MinekPo1 added the bug label Jun 28, 2024
@MinekPo1 MinekPo1 changed the title compile_flags plugin is to selective when filtering flags compile_flags plugin is too selective when filtering flags Jun 28, 2024
@waruqi
Copy link
Member

waruqi commented Jun 29, 2024

? I don't know what you mean. and what is your problem?

@MinekPo1
Copy link
Author

MinekPo1 commented Jun 29, 2024

Oh sorry, I didn't realize that it was unclear!

I've provided files to reproduce the issue here, but in short, the -std=c 23 flag is not written to compile_flags.txt as I feel it should be, which causes tools using the file to report issues which don't come up when building with xmake.

As another example, see msvc's /await flag, which if omitted can cause tooling using compile_flags.txt to possibly not be aware that using corutines is okay and raise syntax errors (not sure if any tooling that exists would use that flag and use compile_flags.txt tbh but oh well).

@SirLynix
Copy link
Member

It looks like it's on purpose:

-- get compile arguments
local arguments = compiler.compflags(sourcefile, {target = target})
for i, flag in ipairs(arguments) do
-- only export the -I*/-D* flags
if flag == "-I" or flag == "/I" or flag == "-isystem" then
table.insert(flags, flag .. arguments[i 1])
elseif flag:find('^-[ID]') or flag:find("-isystem", 1, true) then
table.insert(flags, flag)
end
end

I didn't know about compile_flags, what's the difference with compile_commands?

@waruqi
Copy link
Member

waruqi commented Jun 30, 2024

The implementation of compile_flags is very old and many rule scripts are not implemented. As a result, some flags are missing.

We need some time to do some refactoring to improve it.

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

3 participants