-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
Fix stdmodule culling #5375
Closed
Closed
Fix stdmodule culling #5375
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module my_module; | ||
|
||
import std; | ||
|
||
auto my_sum(std::size_t a, std::size_t b) -> std::size_t { return a + b; } |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export module my_module; | ||
|
||
import std; | ||
|
||
export auto my_sum(std::size_t a, std::size_t b) -> std::size_t; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import("lib.detect.find_tool") | ||
import("core.base.semver") | ||
import("core.tool.toolchain") | ||
import("utils.ci.is_running", {alias = "ci_is_running"}) | ||
|
||
function _build() | ||
local outdata | ||
if ci_is_running() then | ||
local outdata = os.iorun("xmake -rvD") | ||
else | ||
local outdata = os.iorun("xmake -r") | ||
end | ||
if outdata then | ||
if outdata:find("compiling.module.release std") then | ||
raise("STD Module culling does not work\n%s", outdata) | ||
else | ||
print(outdata) | ||
end | ||
end | ||
outdata = os.iorun("xmake") | ||
if outdata then | ||
if outdata:find("compiling") or outdata:find("linking") or outdata:find("generating") then | ||
raise("Modules incremental compilation does not work\n%s", outdata) | ||
end | ||
end | ||
end | ||
|
||
function main(t) | ||
if is_subhost("windows") then | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "19.0") >= 0 then | ||
-- clang don't support msstl std modules atm | ||
-- os.exec("xmake f --toolchain=clang -c --yes") | ||
-- _build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
local msvc = toolchain.load("msvc") | ||
if msvc and msvc:check() then | ||
local vcvars = msvc:config("vcvars") | ||
if vcvars and vcvars.VCInstallDir and vcvars.VCToolsVersion and semver.compare(vcvars.VCToolsVersion, "14.35") then | ||
local stdmodulesdir = path.join(vcvars.VCInstallDir, "Tools", "MSVC", vcvars.VCToolsVersion, "modules") | ||
if os.isdir(stdmodulesdir) then | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f -c --yes") | ||
_build() | ||
end | ||
end | ||
end | ||
elseif is_subhost("msys") then | ||
-- os.exec("xmake f -c -p mingw --yes") | ||
-- _build() | ||
elseif is_host("linux") then -- or is_host("macosx") then | ||
-- gcc don't support std modules atm | ||
-- local gcc = find_tool("gcc", {version = true}) | ||
-- if is_host("linux") and gcc and gcc.version and semver.compare(gcc.version, "11.0") >= 0 then | ||
-- os.exec("xmake f -c --yes") | ||
-- _build() | ||
-- end | ||
local clang = find_tool("clang", {version = true}) | ||
if clang and clang.version and semver.compare(clang.version, "19.0") >= 0 then | ||
-- clang don't support libstdc++ std modules atm | ||
-- os.exec("xmake clean -a") | ||
-- os.exec("xmake f --toolchain=clang -c --yes") | ||
-- _build() | ||
os.exec("xmake clean -a") | ||
os.exec("xmake f --toolchain=clang --runtimes=c++_shared -c --yes") | ||
_build() | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import std; | ||
|
||
import my_module; | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char** argv) { | ||
cout << my_sum(1, 1) << endl; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
add_rules("mode.debug", "mode.release") | ||
set_languages("c++latest") | ||
|
||
target("mod") | ||
set_kind("static") | ||
add_files("src/*.cpp") | ||
add_files("src/*.mpp", {public = true}) | ||
|
||
target("stdmodules") | ||
set_kind("binary") | ||
add_files("test/*.cpp") | ||
add_deps("mod") |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to optimize this many loops? it seems like it would be very slow when the object file is very large.
Or we can build the map to optimize it the first time we traverse the nodes.