Skip to content

Move clang pch to its own module - #7529

Merged
waruqi merged 1 commit into
xmake-io:devfrom
tgsong:fix-clang-pch
May 5, 2026
Merged

Move clang pch to its own module#7529
waruqi merged 1 commit into
xmake-io:devfrom
tgsong:fix-clang-pch

Conversation

@tgsong

@tgsong tgsong commented May 5, 2026

Copy link
Copy Markdown
Contributor

This PR refactors clang pch related logic to its own module instead of hardcoded in gcc. This fixes pch support for tools that inherit from clang like zig cc.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors precompiled header (PCH) flag generation by moving Clang-specific logic from gcc.lua to clang.lua. New functions were added to clang.lua to handle C, C++, ObjC, and ObjC++ respectively. Feedback suggests improving the robustness of these new functions by using 'opt.target or opt' to retrieve the target object, ensuring consistency with existing patterns in the codebase.

-- make the c precompiled header flag
function nf_pcheader(self, pcheaderfile, opt)
if self:kind() == "cc" then
local target = opt.target

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.

        local target = opt.target or opt

-- make the c++ precompiled header flag
function nf_pcxxheader(self, pcheaderfile, opt)
if self:kind() == "cxx" then
local target = opt.target

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.

        local target = opt.target or opt

-- make the objc precompiled header flag
function nf_pmheader(self, pcheaderfile, opt)
if self:kind() == "mm" then
local target = opt.target

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.

        local target = opt.target or opt

-- make the objc++ precompiled header flag
function nf_pmxxheader(self, pcheaderfile, opt)
if self:kind() == "mxx" then
local target = opt.target

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To improve robustness and maintain consistency with other functions in this file (e.g., nf_runtime at line 229), consider using opt.target or opt to retrieve the target object. This ensures the function works correctly even if the target is passed directly as the opt argument.

        local target = opt.target or opt

@waruqi
waruqi merged commit d76ec6a into xmake-io:dev May 5, 2026
37 checks passed
@waruqi waruqi added this to the v3.0.9 milestone May 5, 2026
@tgsong
tgsong deleted the fix-clang-pch branch May 5, 2026 18:49
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