long double usage in swift

Hi,

I was looking at an ABI related issue on Windows. In trying to construct a
test case, it seems that I am unable to import a declaration using a long
double into swift. I was wondering if there is something about long double
usage in swift that I am unaware of.

Inputs/abi.h:

float fp32_call(void);
double fp64_call(void);
long double fp80_call(void);

Inputs/module.map:

module abi {
  header "abi.h"
}

test.swift:

%swift -I Inputs -parse %s
import abi

@inline(never)
func blackhole<T>(t : T) { }

func test_floating_point() {
}

Thanks!

···

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

Sorry, hit send too quickly:

Inputs/abi.h:

float fp32_call(void);
double fp64_call(void);
long double fp80_call(void);

Inputs/module.map:

module abi {
  header "abi.h"
}

test.swift:

%swift -I Inputs -parse %s
import abi

@inline(never)
func blackhole<T>(t : T) { }

func test_floating_point() {
  blackhole(fp32_call())
  blackhole(fp64_call())
if LONG_DOUBLE
  blackhole(fp80_call())
#endif
}

Compiling with -DLONG_DOUBLE will result in an error:
  error: use of unresolved identifier 'fp80_call'.

Ive tested this with clang, and using this in a module (-fmodules
-fmodule-cache-path=/tmp) seems to work fine, so I don't believe that this
is an issue with modules.

···

On Wed, Mar 23, 2016 at 2:25 PM, Saleem Abdulrasool <compnerd@compnerd.org> wrote:

Hi,

I was looking at an ABI related issue on Windows. In trying to construct
a test case, it seems that I am unable to import a declaration using a long
double into swift. I was wondering if there is something about long double
usage in swift that I am unaware of.

Inputs/abi.h:

float fp32_call(void);
double fp64_call(void);
long double fp80_call(void);

Inputs/module.map:

module abi {
  header "abi.h"
}

test.swift:

%swift -I Inputs -parse %s
import abi

@inline(never)
func blackhole<T>(t : T) { }

func test_floating_point() {
}

Thanks!

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

For better or worse, the failure mode for unsupported C declarations in the Clang importer is just to discard them. It sounds like we didn't add support for long double imports.

-Joe

···

On Mar 23, 2016, at 2:25 PM, Saleem Abdulrasool via swift-dev <swift-dev@swift.org> wrote:

Hi,

I was looking at an ABI related issue on Windows. In trying to construct a test case, it seems that I am unable to import a declaration using a long double into swift. I was wondering if there is something about long double usage in swift that I am unaware of.

Inputs/abi.h:

float fp32_call(void);
double fp64_call(void);
long double fp80_call(void);

Inputs/module.map:

module abi {
  header "abi.h"
}

test.swift:

%swift -I Inputs -parse %s
import abi

@inline(never)
func blackhole<T>(t : T) { }

func test_floating_point() {
}

Thanks!

There’s a Float80 type, if you’re looking for an 80-bit floating point value.

Alex

···

On 23 Mar 2016, at 21:25, Saleem Abdulrasool via swift-dev <swift-dev@swift.org> wrote:

Hi,

I was looking at an ABI related issue on Windows. In trying to construct a test case, it seems that I am unable to import a declaration using a long double into swift. I was wondering if there is something about long double usage in swift that I am unaware of.

Inputs/abi.h:

float fp32_call(void);
double fp64_call(void);
long double fp80_call(void);

Inputs/module.map:

module abi {
  header "abi.h"
}

test.swift:

%swift -I Inputs -parse %s
import abi

@inline(never)
func blackhole<T>(t : T) { }

func test_floating_point() {
}

Thanks!

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

There’s a Float80 type, if you’re looking for an 80-bit floating point
value.

Im explicitly trying to import a call from C through the clang-importer (to
ensure that long doubles are imported correctly). As such, unfortunately,
I don't think that the use of Float80 is appropriate in this case.

···

On Wed, Mar 23, 2016 at 2:28 PM, Alex Blewitt <alex.blewitt@gmail.com> wrote:

Alex

> On 23 Mar 2016, at 21:25, Saleem Abdulrasool via swift-dev < > swift-dev@swift.org> wrote:
>
> Hi,
>
> I was looking at an ABI related issue on Windows. In trying to
construct a test case, it seems that I am unable to import a declaration
using a long double into swift. I was wondering if there is something
about long double usage in swift that I am unaware of.
>
> Inputs/abi.h:
>
> float fp32_call(void);
> double fp64_call(void);
> long double fp80_call(void);
>
> Inputs/module.map:
>
> module abi {
> header "abi.h"
> }
>
> test.swift:
>
> %swift -I Inputs -parse %s
> import abi
>
> @inline(never)
> func blackhole<T>(t : T) { }
>
> func test_floating_point() {
> }
>
> Thanks!
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

>
> Hi,
>
> I was looking at an ABI related issue on Windows. In trying to
construct a test case, it seems that I am unable to import a declaration
using a long double into swift. I was wondering if there is something
about long double usage in swift that I am unaware of.
>
> Inputs/abi.h:
>
> float fp32_call(void);
> double fp64_call(void);
> long double fp80_call(void);
>
> Inputs/module.map:
>
> module abi {
> header "abi.h"
> }
>
> test.swift:
>
> %swift -I Inputs -parse %s
> import abi
>
> @inline(never)
> func blackhole<T>(t : T) { }
>
> func test_floating_point() {
> }
>
> Thanks!

For better or worse, the failure mode for unsupported C declarations in
the Clang importer is just to discard them. It sounds like we didn't add
support for long double imports.

Yeah, I figured that out later thanks to the pointer that Alex provided.

···

On Wed, Mar 23, 2016 at 3:54 PM, Joe Groff <jgroff@apple.com> wrote:

> On Mar 23, 2016, at 2:25 PM, Saleem Abdulrasool via swift-dev < > swift-dev@swift.org> wrote:

-Joe

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

Why not?

···

On 23 Mar 2016, at 21:29, Saleem Abdulrasool <compnerd@compnerd.org> wrote:

On Wed, Mar 23, 2016 at 2:28 PM, Alex Blewitt <alex.blewitt@gmail.com <mailto:alex.blewitt@gmail.com>> wrote:
There’s a Float80 type, if you’re looking for an 80-bit floating point value.

Im explicitly trying to import a call from C through the clang-importer (to ensure that long doubles are imported correctly). As such, unfortunately, I don't think that the use of Float80 is appropriate in this case.

Alex

> On 23 Mar 2016, at 21:25, Saleem Abdulrasool via swift-dev <swift-dev@swift.org <mailto:swift-dev@swift.org>> wrote:
>
> Hi,
>
> I was looking at an ABI related issue on Windows. In trying to construct a test case, it seems that I am unable to import a declaration using a long double into swift. I was wondering if there is something about long double usage in swift that I am unaware of.
>
> Inputs/abi.h:
>
> float fp32_call(void);
> double fp64_call(void);
> long double fp80_call(void);
>
> Inputs/module.map:
>
> module abi {
> header "abi.h"
> }
>
> test.swift:
>
> %swift -I Inputs -parse %s
> import abi
>
> @inline(never)
> func blackhole<T>(t : T) { }
>
> func test_floating_point() {
> }
>
> Thanks!
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org <mailto:swift-dev@swift.org>
> https://lists.swift.org/mailman/listinfo/swift-dev

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

Why not?

https://github.com/apple/swift/blob/8d9ef80304d7b36e13619ea50e6e76f3ec9221ba/test/Inputs/clang-importer-sdk/usr/include/ctypes.h#L146

AIUI, Float80 isn't exactly applicable to this test (since I want an
explicit long double to be imported, not whatever the representation of
FP80 happens to be). However, thanks for that pointer, it was able to help
me with my issue. It seems that the clang importer explicitly excludes the
long double type from being mapped. Since long double is made illegal, the
decl is pruned from the generated module, resulting in the unresolved
reference.

···

On Wed, Mar 23, 2016 at 2:35 PM, Alex Blewitt <alex.blewitt@gmail.com> wrote:

On 23 Mar 2016, at 21:29, Saleem Abdulrasool <compnerd@compnerd.org> > wrote:

On Wed, Mar 23, 2016 at 2:28 PM, Alex Blewitt <alex.blewitt@gmail.com> > wrote:

There’s a Float80 type, if you’re looking for an 80-bit floating point
value.

Im explicitly trying to import a call from C through the clang-importer
(to ensure that long doubles are imported correctly). As such,
unfortunately, I don't think that the use of Float80 is appropriate in this
case.

Alex

> On 23 Mar 2016, at 21:25, Saleem Abdulrasool via swift-dev < >> swift-dev@swift.org> wrote:
>
> Hi,
>
> I was looking at an ABI related issue on Windows. In trying to
construct a test case, it seems that I am unable to import a declaration
using a long double into swift. I was wondering if there is something
about long double usage in swift that I am unaware of.
>
> Inputs/abi.h:
>
> float fp32_call(void);
> double fp64_call(void);
> long double fp80_call(void);
>
> Inputs/module.map:
>
> module abi {
> header "abi.h"
> }
>
> test.swift:
>
> %swift -I Inputs -parse %s
> import abi
>
> @inline(never)
> func blackhole<T>(t : T) { }
>
> func test_floating_point() {
> }
>
> Thanks!
>
> --
> Saleem Abdulrasool
> compnerd (at) compnerd (dot) org
> _______________________________________________
> swift-dev mailing list
> swift-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org

--
Saleem Abdulrasool
compnerd (at) compnerd (dot) org