SwiftPM C++ Support


(Harlan Haskins) #1

Hi swift-evolution!

Robert Widmann and I have been working on a Swift wrapper for LLVM (https://github.com/harlanhaskins/LLVMSwift) and we’re lamenting the lack of C++ support in SwiftPM.

Ideally, we’d be able to write C++ files that expose C APIs for LLVM APIs that aren’t yet exposed in the llvm-c API.

Before we write a proposal for C++ files in SwiftPM targets, are there any concerns/things we should consider?

Thanks,
Harlan


(Ankit Agarwal) #2

+ swift-build-dev

···

On Tue, Jan 17, 2017 at 12:03 AM, Harlan Haskins via swift-evolution < swift-evolution@swift.org> wrote:

Hi swift-evolution!

Robert Widmann and I have been working on a Swift wrapper for LLVM (
https://github.com/harlanhaskins/LLVMSwift) and we’re lamenting the lack
of C++ support in SwiftPM.

Ideally, we’d be able to write C++ files that expose C APIs for LLVM APIs
that aren’t yet exposed in the llvm-c API.

Before we write a proposal for C++ files in SwiftPM targets, are there any
concerns/things we should consider?

Thanks,
Harlan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

--
Ankit


(Daniel Dunbar) #3

Hi Harlan,

Can you describe more about exactly what distinct problems you are running
into?

Thanks!
- Daniel

···

On Mon, Jan 16, 2017 at 10:54 AM, Ankit Agarwal via swift-build-dev < swift-build-dev@swift.org> wrote:

+ swift-build-dev

On Tue, Jan 17, 2017 at 12:03 AM, Harlan Haskins via swift-evolution < > swift-evolution@swift.org> wrote:

Hi swift-evolution!

Robert Widmann and I have been working on a Swift wrapper for LLVM (
https://github.com/harlanhaskins/LLVMSwift) and we’re lamenting the lack
of C++ support in SwiftPM.

Ideally, we’d be able to write C++ files that expose C APIs for LLVM APIs
that aren’t yet exposed in the llvm-c API.

Before we write a proposal for C++ files in SwiftPM targets, are there
any concerns/things we should consider?

Thanks,
Harlan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

--
Ankit

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev


(Robert Widmann) #4

One concrete problem we're running into is that we cannot specify a way to invoke clang++, which makes it rather perilous to link against anything LLVM-related on Linux.

~Robert Widmann

2017/01/16 14:51、Daniel Dunbar via swift-evolution <swift-evolution@swift.org> のメッセージ:

···

Hi Harlan,

Can you describe more about exactly what distinct problems you are running into?

Thanks!
- Daniel

On Mon, Jan 16, 2017 at 10:54 AM, Ankit Agarwal via swift-build-dev <swift-build-dev@swift.org> wrote:
+ swift-build-dev

On Tue, Jan 17, 2017 at 12:03 AM, Harlan Haskins via swift-evolution <swift-evolution@swift.org> wrote:
Hi swift-evolution!

Robert Widmann and I have been working on a Swift wrapper for LLVM (https://github.com/harlanhaskins/LLVMSwift) and we’re lamenting the lack of C++ support in SwiftPM.

Ideally, we’d be able to write C++ files that expose C APIs for LLVM APIs that aren’t yet exposed in the llvm-c API.

Before we write a proposal for C++ files in SwiftPM targets, are there any concerns/things we should consider?

Thanks,
Harlan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

--
Ankit

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-build-dev

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Harlan Haskins) #5

-swift-evolution, for now.

I’m trying to build a C++ shim around the LLVM API to create an instance of the ORCJIT, visible in this PR:
https://github.com/trill-lang/LLVMSwift/pull/18

I can’t build this file without passing `-Xcc -std=c++1` to `swift build`. When I pass that (along with the necessary linker flags and include dirs):

`swift build -Xcc -std=c++11 -Xcc -I/usr/local/opt/llvm/include -Xlinker -L/usr/local/opt/llvm/lib -Xlinker -lc++ -Xlinker -lLLVM`

Then It can’t build SwiftShims:

<unknown>:0: error: could not build Objective-C module 'SwiftShims'
<unknown>:0: error: invalid argument '-std=c++11' not allowed with 'C/ObjC'

That’s the issue here — I can’t pass arguments to the C++ files without affecting the C/ObjC files.

Thanks,
Harlan

···

On Jan 16, 2017, at 4:51 PM, Daniel Dunbar via swift-build-dev <swift-build-dev@swift.org> wrote:

Hi Harlan,

Can you describe more about exactly what distinct problems you are running into?

Thanks!
- Daniel

On Mon, Jan 16, 2017 at 10:54 AM, Ankit Agarwal via swift-build-dev <swift-build-dev@swift.org <mailto:swift-build-dev@swift.org>> wrote:
+ swift-build-dev

On Tue, Jan 17, 2017 at 12:03 AM, Harlan Haskins via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
Hi swift-evolution!

Robert Widmann and I have been working on a Swift wrapper for LLVM (https://github.com/harlanhaskins/LLVMSwift) and we’re lamenting the lack of C++ support in SwiftPM.

Ideally, we’d be able to write C++ files that expose C APIs for LLVM APIs that aren’t yet exposed in the llvm-c API.

Before we write a proposal for C++ files in SwiftPM targets, are there any concerns/things we should consider?

Thanks,
Harlan

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

--
Ankit

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org <mailto:swift-build-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-build-dev

_______________________________________________
swift-build-dev mailing list
swift-build-dev@swift.org <mailto:swift-build-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-build-dev