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

[SR-12758] C wrapper library requires custom module map in Swift 5.2 #4550

Closed
yim-lee opened this issue May 9, 2020 · 4 comments
Closed
Assignees
Labels

Comments

@yim-lee
Copy link
Member

yim-lee commented May 9, 2020

Previous ID SR-12758
Radar rdar://problem/63848226
Original Reporter @yim-lee
Type Bug
Status Resolved
Resolution Won't Do

Attachment: Download

Environment

Mac OS 10.15.4

Xcode: Version 11.4.1 (11E503a)

***

Apple Swift version 5.1.3 (swift-5.1.3-RELEASE)

Target: x86_64-apple-darwin19.4.0

***

Apple Swift version 5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51)

Target: x86_64-apple-darwin19.4.0

***

Apple Swift version 5.2.3 (swift-5.2.3-RELEASE)

Target: x86_64-apple-darwin19.4.0

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee @abertelrud
Priority Medium

md5: 3ccd8a2eef170863c7e301bf6d2d6e64

Issue Description:

I have a project that's structured as follows:

{{ - Sources}}
{{ |- Clibuv}}
{{ |- Foo}}

where Clibuv is a wrapper around the libuv library (in real life it's a git submodule under Sources/Clibuv/), and Foo depends on Clibuv. See attached Foo-51.zip.

The project builds fine in Swift 5.1.

With Swift 5.2.3 however, I get errors like these:

While building module 'Clibuv' imported from Foo/Sources/Foo/main.c:2:

In file included from <module-includes>:3:

Foo/Sources/Clibuv/libuv/include/uv/bsd.h:25:9: warning: 'UV_PLATFORM_FS_EVENT_FIELDS' macro redefined [-Wmacro-redefined]

{{#define UV_PLATFORM_FS_EVENT_FIELDS }}

{{ ^}}

Foo/Sources/Clibuv/libuv/include/uv/darwin.h:45:9: note: previous definition is here

#define UV_PLATFORM_FS_EVENT_FIELDS

Checking the build output I see that a module map is automatically generated for Clibuv:

module Clibuv {

{{ umbrella "/Users/ylee/Downloads/Foo/Sources/Clibuv/libuv/include"}}

{{ export *}}

{{}}}

To address the build issue, I add a custom module map under Sources/Clibuv/include/:

module Clibuv {

{{ header "uv.h"}}

{{ export *}}

{{}}}

And updated Package.swift. See Foo-52-fix.zip.

{{ }}

@abertelrud
Copy link
Contributor

@swift-ci create

@abertelrud
Copy link
Contributor

#2813

@abertelrud
Copy link
Contributor

This PR:

#2844

is a smaller change that doesn't change how module maps are generated, but that instead conditionalizes the passing of the additional flag in the original bugfix so that it now checks the swift-tools-version of the package. We can then do an evolution proposal to improve the module generation logic separately from this.

@abertelrud
Copy link
Contributor

After a lot of discussion, the concern was that there could be an unknowable number of packages that relied on the behavior that had been introduced in SwiftPM 5.2, so the PR was withdrawn. We are updating the development documentation to emphasize not changing behavior without conditionalizing it on the swift-tools-version of the package so that future transitions will be smoother, but this doesn't seem to be an issue that can be addressed without a custom module map.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
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