Re: [swift-users] Swift 4.0 LLDBFrontend Crash

2017-10-06 Thread Michael Gottesman via swift-users
It looks like this is failing during guaranteed optimization. Are you running 
an expression in the debugger and we are crashing there?

Michael

> On Oct 6, 2017, at 11:53 AM, Edward Connell via swift-users 
>  wrote:
> 
> While trying to debug a Netlib function, LLDB is crashing
> 
> I'm not sure what this assert means.
> 
> LLDBFrontend: 
> /home/buildnode/jenkins/workspace/oss-swift-4.0-package-linux-ubuntu-16_04/swift/lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp:613:
>  (anonymous namespace)::SourceAccess (anonymous 
> namespace)::AccessEnforcementSelection::getSourceAccess(swift::SILValue): 
> Assertion `isa(address) || isa(address)' failed.
> Stack dump:
> 0.While running pass #10 SILModuleTransform ""Access Enforcement 
> Selection"".
> 
> It fails every time and the same way in several functions, but not all 
> functions.
> I tried to create a simple repro with the same function signature, but I 
> can't get the simple case to fail.
> A debug build isn't doing whole-module-optimization, so that's not it
> 
> Ideas anyone?
> 
> Who owns the LLDBFrontend?
> 
> Thanks, Ed
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Swift for Nuttx RTOS

2017-10-06 Thread Igor Mironenko via swift-users
Thanks Alex,

This is similar to what I though. Appreciate you taking time to explain.



> On Oct 6, 2017, at 1:38 AM, Alex Blewitt  wrote:
> 
>> On 5 Oct 2017, at 22:47, Igor Mironenko via swift-users 
>>  wrote:
>> 
>> This may be a strange question, but I would like to understand, since both 
>> Mac OS and Nuttx RTOS are POSIX certified would it be possible in any way to 
>> create a program using Swift language but compile to run it on Nuttx? 
>> 
>> Is it something that would require a special compiler to be build 
>> specifically for Nuttx, just like there is one for Swift for Linux? In my 
>> understanding Swift compiles to a binary code and does work with C/C++. What 
>> am I missing here? I googled and looks like I'm the only one interested in 
>> such work.
> 
> Hi Igor,
> 
> Currently Swift requires libraries such as libswiftCore to be compiled for 
> the target platform before being able to compile Swift programs for that 
> platform. This has a number of dependencies, including being able to build a 
> custom build of clang and other support libraries such as dispatch and 
> foundation.
> 
> While there is work that allows this project to be compiled for Linux 
> platforms, and others are working on porting it to Android, and other more 
> estoteric platforms, there's nothing been done so far (that I'm aware of) 
> that has targetted Nuttx.
> 
> You are likely to have to do some work in order to get Swift building on 
> Nuttx first - once that's done, you may be able to cross-compile programs 
> from a Mac to do there.
> 
> Alex

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Swift 4.0 LLDBFrontend Crash

2017-10-06 Thread Edward Connell via swift-users
While trying to debug a Netlib function, LLDB is crashing

I'm not sure what this assert means.

*LLDBFrontend:
/home/buildnode/jenkins/workspace/oss-swift-4.0-package-linux-ubuntu-16_04/swift/lib/SILOptimizer/Mandatory/AccessEnforcementSelection.cpp:613:
(anonymous namespace)::SourceAccess (anonymous
namespace)::AccessEnforcementSelection::getSourceAccess(swift::SILValue):
Assertion `isa(address) || isa(address)' failed.*
*Stack dump:*
*0. While running pass #10 SILModuleTransform ""Access Enforcement
Selection"".*

It fails every time and the same way in several functions, but not all
functions.
I tried to create a simple repro with the same function signature, but I
can't get the simple case to fail.
A debug build isn't doing whole-module-optimization, so that's not it

Ideas anyone?

Who owns the LLDBFrontend?

Thanks, Ed
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-06 Thread Geordie Jay via swift-users
I think SwiftPM is (incorrectly) compiling A.XYZ into each of the modules
that depend on it, as well as into your intended libA.so file.

Try to ensure the plugin provider module (libA) is (only) being compiled
into its standalone shared library file. Try cleaning the swiftpm build for
one (swift package clean) and ensure the Package.swift files are correctly
set up to output the shared library.

Sorry I can’t be more specific, I’ve had these same kinds of issues before
but I’m not 100% what they were.

Geordie


Ján Kosa via swift-users  schrieb am Fr. 6. Okt.
2017 um 14:41:

> It worked! Took me a while to iron out details, but it is working now.
> Huge thanks sir, I will name my firstborn after you.
> Thanks for the @_cdecl("initializePlugin") tip as well, I didn't know
> about it and it will be very useful.
>
> I am having slightly related problem now (it was there before, but I
> ignored it for the time being), not sure if I should start a new thread?
>
> The PluginInterface module has one external dependency on module A,
> PluginConsumer has the dependency on module B which has dependency on same
> module A that the PluginInterface uses. When I load the plugin library, I
> get bunch of errors like:
>
> Class A.XYZ is implemented in both libPluginInterface.dylib and
> libMyPlugin.dylib
>
> I know why it is there, but I don't know how to get rid of it. I can't
> just remove dependency from PluginConsumer and use the one from
> PluginInterface (if that would even work?) because PluginConsumer does not
> depend on it directly, but it is going through module B first
>
> Cheers,
> Lope
>
> On 4 October 2017 at 22:17, Daniel Dunbar  wrote:
>
>> The way that I have done this in the past is pass a protocol as an unsafe
>> pointer to an exposed entry point:
>> ```swift
>> let entryPoint = dlsym(handle, “initializePlugin”)
>> guard entryPoint != nil else {
>> fatalError("missing plugin entry point: \(pluginPath)")
>> }
>> typealias PluginInitializationFunc = @convention(c)
>> (UnsafeRawPointer) -> ()
>> let f = unsafeBitCast(entryPoint, to:
>> PluginInitializationFunc.self)
>> f(Unmanaged.passUnretained(self).toOpaque())
>> ```
>>
>> and then in the plugin convert back to the appropriate type:
>>
>> ```
>> @_cdecl("initializePlugin")
>> public func initializePlugin(_ ptr: UnsafeRawPointer) {
>> let manager =
>> Unmanaged.fromOpaque(ptr).takeUnretainedValue()
>> ```
>>
>> HTH,
>>  - Daniel
>>
>> On Oct 4, 2017, at 11:02 AM, Ján Kosa via swift-users <
>> swift-users@swift.org> wrote:
>>
>> Hello folks,
>>
>> I have been toying with dynamic libraries, trying to implement plugin
>> functionality. I was able to get to the point where I can call simple
>> function in loaded library, but I am having troubles starting more
>> sophisticated communication channel.
>>
>> There are 3 projects
>> - PluginConsumer is an app that loads plugin libraries
>> - MyPlugin is a plugin implementation, output is dynamic library that
>> PluginConsumer loads
>> - PluginInterface is common interface that both MyPlugin and
>> PluginConsumer use, so that they know how to communicate
>>
>> My first idea was to have PluginInterface be a simple SPM project with
>> single file where the bare-bones PluginInterface class would be:
>>
>>
>> open class PluginInterface {
>>
>> open func sayHi()
>>
>> }
>>
>>
>> Package.swift file:
>>
>>
>> // swift-tools-version:4.0
>>
>> import PackageDescription
>>
>> let package = Package(
>>
>> name: "PluginInterface",
>>
>> products: [ .library(name: "PluginInterface", type: .dynamic,
>> targets: ["PluginInterface"]) ],
>>
>> targets: [ .target(name: "PluginInterface") ]
>>
>> )
>>
>>
>>
>> UserPlugin is also very simple project containing only one file:
>>
>>
>> public func getPlugin() -> AnyObject {
>>
>> return MyPlugin()
>>
>> }
>>
>>
>> class MyPlugin: PluginInterface {
>>
>> override func sayHi() {
>>
>> print("Hi from my plugin")
>>
>> }
>>
>> }
>>
>> Package.swift:
>>
>>
>> // swift-tools-version:4.0
>>
>> import PackageDescription
>>
>> let package = Package(
>>
>> name: "MyPlugin",
>>
>> products: [ .library(name: "MyPlugin", type: .dynamic, targets: [
>> "MyPlugin"]) ],
>>
>> dependencies: [ .package(url: "url_to_PluginInterface", from: "0.0.0"),
>> ],
>>
>> targets: [
>>
>> .target(name: "PluginInterface", dependencies: ["PluginInterface"
>> ]),
>>
>> .target(name: "MyPlugin", dependencies: ["PluginInterface"]),
>>
>> ]
>>
>> )
>>
>>
>> The PluginConsumer is bit more complicated, but here is relevant part
>> (lib loading and function calling):
>>
>>
>> typealias InitFunction = @convention(c) () -> AnyObject
>>
>>
>> let openRes = dlopen(pathToLib, RTLD_NOW|RTLD_LOCAL)
>>
>> if openRes != nil {
>>
>> defer {
>>
>> dlclose(openRes)
>>
>> }
>>
>> let symbolName = 

Re: [swift-users] Communicating with dynamically loaded swift library

2017-10-06 Thread Ján Kosa via swift-users
It worked! Took me a while to iron out details, but it is working now. Huge
thanks sir, I will name my firstborn after you.
Thanks for the @_cdecl("initializePlugin") tip as well, I didn't know about
it and it will be very useful.

I am having slightly related problem now (it was there before, but I
ignored it for the time being), not sure if I should start a new thread?

The PluginInterface module has one external dependency on module A,
PluginConsumer has the dependency on module B which has dependency on same
module A that the PluginInterface uses. When I load the plugin library, I
get bunch of errors like:

Class A.XYZ is implemented in both libPluginInterface.dylib and
libMyPlugin.dylib

I know why it is there, but I don't know how to get rid of it. I can't just
remove dependency from PluginConsumer and use the one from PluginInterface
(if that would even work?) because PluginConsumer does not depend on it
directly, but it is going through module B first

Cheers,
Lope

On 4 October 2017 at 22:17, Daniel Dunbar  wrote:

> The way that I have done this in the past is pass a protocol as an unsafe
> pointer to an exposed entry point:
> ```swift
> let entryPoint = dlsym(handle, “initializePlugin”)
> guard entryPoint != nil else {
> fatalError("missing plugin entry point: \(pluginPath)")
> }
> typealias PluginInitializationFunc = @convention(c)
> (UnsafeRawPointer) -> ()
> let f = unsafeBitCast(entryPoint, to:
> PluginInitializationFunc.self)
> f(Unmanaged.passUnretained(self).toOpaque())
> ```
>
> and then in the plugin convert back to the appropriate type:
>
> ```
> @_cdecl("initializePlugin")
> public func initializePlugin(_ ptr: UnsafeRawPointer) {
> let manager = Unmanaged.fromOpaque(ptr).
> takeUnretainedValue()
> ```
>
> HTH,
>  - Daniel
>
> On Oct 4, 2017, at 11:02 AM, Ján Kosa via swift-users <
> swift-users@swift.org> wrote:
>
> Hello folks,
>
> I have been toying with dynamic libraries, trying to implement plugin
> functionality. I was able to get to the point where I can call simple
> function in loaded library, but I am having troubles starting more
> sophisticated communication channel.
>
> There are 3 projects
> - PluginConsumer is an app that loads plugin libraries
> - MyPlugin is a plugin implementation, output is dynamic library that
> PluginConsumer loads
> - PluginInterface is common interface that both MyPlugin and
> PluginConsumer use, so that they know how to communicate
>
> My first idea was to have PluginInterface be a simple SPM project with
> single file where the bare-bones PluginInterface class would be:
>
>
> open class PluginInterface {
>
> open func sayHi()
>
> }
>
>
> Package.swift file:
>
>
> // swift-tools-version:4.0
>
> import PackageDescription
>
> let package = Package(
>
> name: "PluginInterface",
>
> products: [ .library(name: "PluginInterface", type: .dynamic,
> targets: ["PluginInterface"]) ],
>
> targets: [ .target(name: "PluginInterface") ]
>
> )
>
>
>
> UserPlugin is also very simple project containing only one file:
>
>
> public func getPlugin() -> AnyObject {
>
> return MyPlugin()
>
> }
>
>
> class MyPlugin: PluginInterface {
>
> override func sayHi() {
>
> print("Hi from my plugin")
>
> }
>
> }
>
> Package.swift:
>
>
> // swift-tools-version:4.0
>
> import PackageDescription
>
> let package = Package(
>
> name: "MyPlugin",
>
> products: [ .library(name: "MyPlugin", type: .dynamic, targets: [
> "MyPlugin"]) ],
>
> dependencies: [ .package(url: "url_to_PluginInterface", from: "0.0.0"),
> ],
>
> targets: [
>
> .target(name: "PluginInterface", dependencies: ["PluginInterface"
> ]),
>
> .target(name: "MyPlugin", dependencies: ["PluginInterface"]),
>
> ]
>
> )
>
>
> The PluginConsumer is bit more complicated, but here is relevant part (lib
> loading and function calling):
>
>
> typealias InitFunction = @convention(c) () -> AnyObject
>
>
> let openRes = dlopen(pathToLib, RTLD_NOW|RTLD_LOCAL)
>
> if openRes != nil {
>
> defer {
>
> dlclose(openRes)
>
> }
>
> let symbolName = "mangled_symbol_name"
>
> let sym = dlsym(openRes, symbolName)
>
>
> if sym != nil {
>
> let f: InitFunction = unsafeBitCast(sym, to: InitFunction.self)
>
> let plugin = f() as? PluginInterface
>
> }
>
> }
>
> Package.swift file:
>
> // swift-tools-version:4.0
>
> import PackageDescription
>
> let package = Package(
>
> name: "PluginConsumer",
>
> dependencies: [ .package(url: "path_to_plugin_interface", from:
> "0.0.0") ],
>
> targets: [ .target(name: "PluginConsumer", dependencies: [
> "PluginConsumer"]) ]
>
> )
>
>
> This all compiles nicely, MyPlugin project creates dylib file that
> executable created by PluginConsumer can load, but the problem is with
> following line:
>
> let plugin = f() as? PluginInterface
>
> Type of the plugin is MyPlugin, 

Re: [swift-users] Is URLSession actually working on Linux

2017-10-06 Thread Alex Blewitt via swift-users
> On 5 Oct 2017, at 19:18, Georgios Moschovitis  
> wrote:
> 
> I am wondering, is there an ETA for 4.0.1 ?

I'm not aware of there being an ETA, but according to 
https://swift.org/download/ last year Swift 3.0 was released on September 13, 
2016 and then a subsequent Swift 3.0.1 was released on October 28, 2016. 

Alex
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Swift for Nuttx RTOS

2017-10-06 Thread Alex Blewitt via swift-users
> On 5 Oct 2017, at 22:47, Igor Mironenko via swift-users 
>  wrote:
> 
> This may be a strange question, but I would like to understand, since both 
> Mac OS and Nuttx RTOS are POSIX certified would it be possible in any way to 
> create a program using Swift language but compile to run it on Nuttx? 
> 
> Is it something that would require a special compiler to be build 
> specifically for Nuttx, just like there is one for Swift for Linux? In my 
> understanding Swift compiles to a binary code and does work with C/C++. What 
> am I missing here? I googled and looks like I'm the only one interested in 
> such work.

Hi Igor,

Currently Swift requires libraries such as libswiftCore to be compiled for the 
target platform before being able to compile Swift programs for that platform. 
This has a number of dependencies, including being able to build a custom build 
of clang and other support libraries such as dispatch and foundation.

While there is work that allows this project to be compiled for Linux 
platforms, and others are working on porting it to Android, and other more 
estoteric platforms, there's nothing been done so far (that I'm aware of) that 
has targetted Nuttx.

You are likely to have to do some work in order to get Swift building on Nuttx 
first - once that's done, you may be able to cross-compile programs from a Mac 
to do there.

Alex
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] [Quantlib-users] Unrelated to QuantLib, but your help is very highly appreciated

2017-10-06 Thread TUNG CK via swift-users
The correct approach is to use .mm for your file extension. 


> Amine Ifri  於 2017年10月6日 上午2:39 寫道:
> 
> Hi community,
> 
> As I have recently upgraded my OS and IDE on Mac to Xcode 9.0, I have 
> recompiled successfully QuantLib using c++11/ libc++. 
> 
> I am in the process of building a small application that relies on QL. 
> However, I run into a very irritating problem - that doesn’t have anything to 
> do with QL - that has kept me from being productive today. Apparently, it is 
> related to the  header which includes the C-header  and 
> imports some of its functionalities into the std namespace, but I end up with 
> a bunch of errors stating that for the following functions: 
> 
> using ::signbit;
> using ::fpclassify;
> using ::isfinite;
> using ::isinf;
> using ::isnan;
> using ::isnormal;
> using ::isgreater;
> using ::isgreaterequal;
> using ::isless;
> using ::islessequal;
> using ::islessgreater;
> using ::isunordered;
> using ::isunordered;
> 
> They can’t be found in the global namespace. I have spent a lot of time on 
> the web looking for a solution, but haven’t been any successful. If any of 
> you has ever encountered such issue and is willing to help, I would be very 
> very grateful.
> 
> Thanks,
> Amine
> 
> --
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> ___
> QuantLib-users mailing list
> quantlib-us...@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users