Thread overview
Is there a way to use x86 and x86_mscoff with dub simultaneously.
Jul 25, 2017
ciechowoj
Jul 25, 2017
Mike Parker
Jul 25, 2017
Jacob Carlborg
Jul 25, 2017
ciechowoj
Jul 25, 2017
Sönke Ludwig
Jul 26, 2017
Jacob Carlborg
Jul 30, 2017
ciechowoj
July 25, 2017
Currently dub reports following message when the -m32mscoff flag is specified in dub.json.


```
-m32mscoff: Use --arch=x86/--arch=x86_64/--arch=x86_mscoff to specify the target architecture, e.g. 'dub build --arch=x86_64'
```

The problem is after the change the user is unable to build the project just with `dub build` (they need to specify the arch explicitly).

Is there a way to avoid the requirement for specifying the architecture explicitly or at least provide a meaningful message to the user that they should use `--arch=x86_mscoff` ?

Or a way to force dub to use VS linker instead of OPTLINK for x86 case?
Or a way to override the default architecture?
July 25, 2017
On Tuesday, 25 July 2017 at 14:17:54 UTC, ciechowoj wrote:
> Currently dub reports following message when the -m32mscoff flag is specified in dub.json.
>
>
> ```
> -m32mscoff: Use --arch=x86/--arch=x86_64/--arch=x86_mscoff to specify the target architecture, e.g. 'dub build --arch=x86_64'

> architecture explicitly or at least provide a meaningful message to the user that they should use `--arch=x86_mscoff` ?

What's wrong with the current error message? Doesn't it do that?

>
> Or a way to force dub to use VS linker instead of OPTLINK for x86 case?
> Or a way to override the default architecture?

That's precisely what --arch (or simply -a) is for. But you can avoid passing it explicitly by setting the $DUB_ARCH environment variable (as per the dub documentation).
July 25, 2017
On 2017-07-25 17:18, Mike Parker wrote:

> That's precisely what --arch (or simply -a) is for. But you can avoid passing it explicitly by setting the $DUB_ARCH environment variable (as per the dub documentation).

The use case is for DStep which requires to link with the Microsoft tool chain since the Clang libraries are only available in the COFF format. To make it as convenient as possible it would be nice to be able to specify in the dub.json without getting warnings.

-- 
/Jacob Carlborg
July 25, 2017
As Jacob Carlborg said it's for the dstep.

On Tuesday, 25 July 2017 at 15:18:04 UTC, Mike Parker wrote:
> On Tuesday, 25 July 2017 at 14:17:54 UTC, ciechowoj wrote:
> What's wrong with the current error message? Doesn't it do that?

Nope, this message looks like intended for the library author rather than for a library user.

What I want is a message that signals that the compilation isn't possible with the default x86 arch and the user has to use x86_mscoff arch.

> That's precisely what --arch (or simply -a) is for. But you can avoid passing it explicitly by setting the $DUB_ARCH environment variable (as per the dub documentation).

To disable the warning I mentioned in the first post I needed to remove the `-m32mscoff` flag. Now the library can be compiled only with explicit specification of the architecture.

However the default arch is what the library's end user will select most likely.
And then they will receive unhelpful message about OPTLINK being unable to parse the VS linker command line.

Ideally I would like to be able to suppress m32mscoff warning and build for x86_mscoff by default (or amd64).

Setting $DUB_ARCH is unacceptable as well.


July 26, 2017
Am 25.07.2017 um 20:47 schrieb ciechowoj:
> As Jacob Carlborg said it's for the dstep.
>
> On Tuesday, 25 July 2017 at 15:18:04 UTC, Mike Parker wrote:
>> On Tuesday, 25 July 2017 at 14:17:54 UTC, ciechowoj wrote:
>> What's wrong with the current error message? Doesn't it do that?
>
> Nope, this message looks like intended for the library author rather
> than for a library user.
>
> What I want is a message that signals that the compilation isn't
> possible with the default x86 arch and the user has to use x86_mscoff arch.
>
>> That's precisely what --arch (or simply -a) is for. But you can avoid
>> passing it explicitly by setting the $DUB_ARCH environment variable
>> (as per the dub documentation).
>
> To disable the warning I mentioned in the first post I needed to remove
> the `-m32mscoff` flag. Now the library can be compiled only with
> explicit specification of the architecture.
>
> However the default arch is what the library's end user will select most
> likely.
> And then they will receive unhelpful message about OPTLINK being unable
> to parse the VS linker command line.
>
> Ideally I would like to be able to suppress m32mscoff warning and build
> for x86_mscoff by default (or amd64).
>
> Setting $DUB_ARCH is unacceptable as well.
>
>

What you can do is to create a configuration that only works for x86_64:

    name "myproject"

    configuration "library" {
        platforms "x86_64"
        targetType "library"
        // ...
    }

This will cause the configuration resolution to fail if the wrong architecture is selected. The downside is that I think the error message will not be very helpful currently (something like "could not resolve configuration for myproject"), but that should be fixable.
July 26, 2017
On 2017-07-26 00:41, Sönke Ludwig wrote:

> What you can do is to create a configuration that only works for x86_64:
> 
>      name "myproject"
> 
>      configuration "library" {
>          platforms "x86_64"
>          targetType "library"
>          // ...
>      }
> 
> This will cause the configuration resolution to fail if the wrong architecture is selected. The downside is that I think the error message will not be very helpful currently (something like "could not resolve configuration for myproject"), but that should be fixable.

It needs to work for 32bit as well. But for 32bit it would only work with COFF.

-- 
/Jacob Carlborg
July 30, 2017
What do you think about adding an optional config value `defaultArch` to dub? It would be used when no arch is specified.

I could specify default arch as x86_64 and everything would be fine.