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-10019] Pass -fcf-runtime-abi=swift to clang on Linux #4727

Open
kevints mannequin opened this issue Feb 28, 2019 · 3 comments
Open

[SR-10019] Pass -fcf-runtime-abi=swift to clang on Linux #4727

kevints mannequin opened this issue Feb 28, 2019 · 3 comments
Labels

Comments

@kevints
Copy link
Mannequin

kevints mannequin commented Feb 28, 2019

Previous ID SR-10019
Radar None
Original Reporter @kevints
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 41b6ca6e1389c95276c1020e607e53f5

Issue Description:

Now that we're bundling clang in snapshot toolchains we should be able to pass -fcf-runtime-abi=swift as well as -I/path/to/usr/lib/swift to clang. This will allow C targets to include CoreFoundation headers and participate in bridging. This is already possible if these flags are passed in, but I don't see why SwiftPM shouldn't pass them automatically.

Example:

root@bacccc9eabda:/test-package# PATH=/swift-DEVELOPMENT-SNAPSHOT-2019-02-26-a-ubuntu16.04/usr/bin:$PATH swift test -Xcc -fcf-runtime-abi=swift-5.0 -Xcc -I/swift-DEVELOPMENT-SNAPSHOT-2019-02-26-a-ubuntu16.04/usr/lib/swift
[5/5] Linking ./.build/x86_64-unknown-linux/debug/test-packagePackageTests.xctest
Test Suite 'All tests' started at 2019-02-28 17:20:56.427
Test Suite 'debug.xctest' started at 2019-02-28 17:20:56.428
Test Suite 'test_packageTests' started at 2019-02-28 17:20:56.429
Test Case 'test_packageTests.testExample' started at 2019-02-28 17:20:56.429
test a cfstr
Test Case 'test_packageTests.testExample' passed (0.0 seconds)
Test Suite 'test_packageTests' passed at 2019-02-28 17:20:56.429
     Executed 1 test, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
Test Suite 'debug.xctest' passed at 2019-02-28 17:20:56.429
     Executed 1 test, with 0 failures (0 unexpected) in 0.0 (0.0) seconds
Test Suite 'All tests' passed at 2019-02-28 17:20:56.429

root@bacccc9eabda:/test-package# cat Sources/CLibTest/include/CLibTest.h
#include <CoreFoundation/CoreFoundation.h>

extern const _Nonnull CFStringRef kTestACFString;
root@bacccc9eabda:/test-package# cat Sources/CLibTest/CLibTest.c
#include <CLibTest.h>

#include <CoreFoundation/CoreFoundation.h>

const CFStringRef kTestACFString = CFSTR("test a cfstr");
root@bacccc9eabda:/test-package# cat Sources/test-package/test_package.swift
import Foundation
import CLibTest

struct test_package {
    var text = "Hello, World!"

    func test(string: String) {
        print(string)
    }

    func test() {
        test(string: kTestACFString as! String)
    }
}
@weissi
Copy link
Member

weissi commented Mar 11, 2019

@belkadan / @millenomi / @aciidb0mb3r I think we should just make the -Xcc -fcf-runtime-abi=swift-5.0 flag the default on Linux? I don't really see a reason to build with any other CF ABI setting.

@belkadan
Copy link

Passing -Xcc flags is generally Bad because they're not guaranteed to be stable. @rjmccall, what do you think about this specific case, though?

@belkadan
Copy link

Oh, whoops, I got -Xcc mixed up with -Xclang (which is Clang's equivalent of Swift's -Xfrontend). This probably makes sense, then.

@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
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

3 participants