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

Generate dependencies of preprocessed modules to avoid importing #ifdef import #3122

Merged
merged 11 commits into from
Dec 2, 2022

Conversation

Arthapz
Copy link
Member

@Arthapz Arthapz commented Nov 30, 2022

No description provided.

@Arthapz Arthapz marked this pull request as draft November 30, 2022 17:40
@@ -150,7 +150,16 @@ function generate_dependencies(target, sourcebatch, opt)

-- no support of p1689 atm
local jsonfile = path.translate(path.join(outputdir, path.filename(sourcefile) .. ".json"))
common.fallback_generate_dependencies(target, jsonfile, sourcefile)
common.fallback_generate_dependencies(target, jsonfile, sourcefile, function(file)
local compinst = target:compiler("cxx")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        local clang, toolname = target:tool("cxx")
        assert(toolname == "clang")
        -- ...
        os.vrunv(clang, table.join(defines, {"-E", "-x", "c++", file,  "-o", ifile}))

Copy link
Member

@waruqi waruqi Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we can use

    local compinst = compiler.load("cxx", {target = target})
    local compflags = table.join("-E", "-x", "c++", compinst:compflags({target = target}))
    os.vrunv(compinst:program(), table.join(compflags, "-o", ifile))

and remove it, because compflags contain them and more too.

local defines = {}
                for _, define in ipairs(target:get("defines")) do
                    table.insert(defines, "-D" .. define)
                end

Copy link
Member Author

@Arthapz Arthapz Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i did use compflags at first but when some flags that are in compflags (like -std=c++20 for clang or -fmodule-ts for gcc) prevent -E from working (the compiler try to search module imports, we don't want that)

update msvc.lua


update msvc.lua


update clang.lua


update msvc.lua
@Arthapz Arthapz marked this pull request as ready for review December 1, 2022 11:37
@Arthapz
Copy link
Member Author

Arthapz commented Dec 1, 2022

Ah i need to take care of dependency include directories, or the preprocessing will fail

fatal error: 'xxx.h' file not found

@Arthapz
Copy link
Member Author

Arthapz commented Dec 1, 2022

it's seem we can't do anything more for clang without llvm/llvm-project#51792
llvm/llvm-project#59287 (comment)

@waruqi waruqi merged commit 5fc4530 into xmake-io:dev Dec 2, 2022
@waruqi
Copy link
Member

waruqi commented Dec 2, 2022

thanks!

@Arthapz
Copy link
Member Author

Arthapz commented Dec 2, 2022

Maybe soon i can add support of p1689 for clang llvm/llvm-project#57293 (comment)

@Arthapz Arthapz deleted the process_modules branch February 3, 2024 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants