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

swift多文件编译未合并在同一个module中造成编译失败 #3916

Closed
ghost opened this issue Jul 3, 2023 · 10 comments
Closed

swift多文件编译未合并在同一个module中造成编译失败 #3916

ghost opened this issue Jul 3, 2023 · 10 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 3, 2023

Xmake 版本

2.7.9+20230515

操作系统版本和架构

macOS 13.4.1 (22F82)

描述问题

在swift的语法中, 允许通过一次性将多个文件输入swiftc中, 作为一个module进行编译:

例:

// A.swift
func test() {}

// B.swift
test()

swiftc -o Test A.swift B.swift // success

然而在xmake的处理中, 每个文件被分开进行编译, 这就使得例中的B.swift因找不到符号导致编译失败.

期待的结果

正常通过编译

工程配置

No response

附加信息和错误日志

No response

@ghost ghost added the bug label Jul 3, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: swift multi-file compilation is not merged in the same module, resulting in compilation failure

Xmake version

2.7.9+20230515

OS version and architecture

macOS 13.4.1 (22F82)

Describe the problem

In the syntax of swift, it is allowed to compile multiple files as a module by inputting them into swiftc at one time:

example:

// A. swift
func test() {}

// B. swift
test()

swiftc -o Test A.swift B.swift // success

However, in the processing of xmake, each file is compiled separately, which makes the compilation of B.swift in the example fail because the symbol cannot be found.

Expected results

Compiled normally

Project configuration

No response

Additional information and error logs

No response

@waruqi
Copy link
Member

waruqi commented Jul 3, 2023

合并成一条命令编译,类似 rust 这种,尽管可以,改动太大,并且有很多局限性,比如无法细粒度设置单独每个 swift 文件的 flags 。。也没法做并行编译优化。。所以能不搞一起 尽量不搞一起。。

可以先先研究下拆分 obj 编译时候的 module 支持方案,我记得应该是可以的,比如用 modulemap 什么的,但是具体怎么弄,要花时间分析,这块先放着吧,最近也没太多时间。。或者你可以先自己研究下 如何单独编译某个 swift 时候,支持引入其他 module 符号

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Combined into one command to compile, similar to rust, although it is possible, the changes are too large, and there are many limitations, such as the inability to set the flags of each individual swift file in a fine-grained manner. . There is no way to do parallel compilation optimization. . So try not to get together if you can. .

You can first study the module support scheme when compiling the split obj. I remember that it should be possible, such as using modulemap or something, but how to do it will take time to analyze. Let’s put this one first, and there are not too many recently. time. . Or you can study on your own how to import other module symbols when compiling a swift separately

@waruqi
Copy link
Member

waruqi commented Jul 8, 2023

你先提供个可复现的完整 example project 过来

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


You first provide a complete example project that can be reproduced

@ghost
Copy link
Author

ghost commented Jul 9, 2023

你先提供个可复现的完整 example project 过来

test.zip

@waruqi
Copy link
Member

waruqi commented Jul 10, 2023

再试试,xmake update -s dev

@waruqi waruqi added this to the v2.8.1 milestone Jul 10, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Try again, xmake update -s dev

@ghost
Copy link
Author

ghost commented Jul 10, 2023

再试试,xmake update -s dev

我手头上的工程没问题了👌

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Try again, xmake update -s dev

I have no problem with the project at hand👌

@waruqi waruqi closed this as completed Jul 10, 2023
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

2 participants