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

LDC 1.5 beta1, Ubuntu 14.04: Exceptions not caught when using gold linker and static linking #2390

Closed
jondegenhardt opened this issue Oct 27, 2017 · 9 comments

Comments

@jondegenhardt
Copy link
Contributor

jondegenhardt commented Oct 27, 2017

Using the gold linker with -static, the built app is not able to catch exceptions and exits instead.

Ubuntu 14.04
LDC 1.5.0-beta1

Program (app.d):

import std.stdio;
import std.conv : to;

int main(string[] args)
{
    if (args.length != 2)
    {
        writeln("Provide an arg to interpret as a integer");
        return 1;
    }

    try
    {
        int x = args[1].to!int;
        writeln("Value: ", x);
    }
    catch (Exception e)
    {
        writeln("Exception caught: ", e.msg);
        return 1;
    }
    return 0;
}

All of these build forms work fine:

$ ldc2 app.d
$ ldc2 -static app.d
$ ldc2 -Xcc=-fuse-ld=gold app.d

Behavior of the above builds (as expected):

$ ldc2 app.d
$ ./app 10
Value: 10
$ ./app 10.5
Exception caught: Unexpected '.' when converting from type string to type int

Combining the gold linker and static linking causes trouble catching the exception:

$ ldc2 -Xcc=-fuse-ld=gold -static app.d
$ ./app 10
Value: 10
$ ./app 10.5
Aborted

I've also tried building with thin and full LTO and multiple programs. The above behavior occurs whenever static linking is combined with the goal linker.

@kinke
Copy link
Member

kinke commented Oct 27, 2017

Works for me on Ubuntu 16.04 using gold v1.11.

@kinke kinke changed the title LDC 1.5 beta1, Linux: Exceptions not caught when using gold linker and static linking LDC 1.5 beta1, Ubuntu 14.04: Exceptions not caught when using gold linker and static linking Oct 27, 2017
@jondegenhardt
Copy link
Contributor Author

Verified. Unbuntu 16.04 works for me as well.

I hit the problem on ubuntu when using Travis-CI. The latest version of ubuntu Travis supports is 14.04. I used dockerized versions of ubuntu 14.04 and 16.04 to verify the behavior. The gold version is 1.11 on both, but the glibc versions are different (2.19 vs 2.23)

@kinke
Copy link
Member

kinke commented Oct 27, 2017

You can use docker with Travis: https://docs.travis-ci.com/user/docker/

@jondegenhardt
Copy link
Contributor Author

jondegenhardt commented Oct 27, 2017

Yeah, I'll have to look into docker. I only need the gold linker for LTO, for non-LTO builds it's fine. It'd be nice to have a successful LTO build on Travis. I've already got the OS X version is going.

One possibility might be to have the LDC docker image available from the docker store updated to use ubuntu 16.04 and LDC 1.5. It'd be convenient if that could be invoked from Travis.

Update: Just checked, the LDC docker image uses 16.04, it's just not on LDC 1.5 yet.

@kinke
Copy link
Member

kinke commented Oct 27, 2017

You basically need a base image with gcc. The official gcc Docker image is based on (recent) Debian and pretty large IIRC (but I guess Travis already has it in some cache); using that one and downloading & extracting an LDC release package should suffice (libcurl3 might be needed additionally).

@jondegenhardt
Copy link
Contributor Author

Thanks the follow-up. Given that ubuntu 16.04 works, it's fine with me if you want to close this as won't fix.

@kinke kinke closed this as completed Oct 27, 2017
@jondegenhardt
Copy link
Contributor Author

I was able to use the updated dlanguage/ldc docker image to build with Ubuntu 16.04 on Travis:

The updated image supports the ldc-build-runtime as well as ldc2, and likely other tools in the LDC package, though I didn't test them. It does include cmake/make and libcurl3 needed by ldc-build-runtime. This turned out to be convenient, as it allowed my entire build process to run via the docker image.

Currently it's necessary to specify the 1.5.0 tag explicitly (ie. dlanguage/ldc:1.5.0). Latest points to the beta, at least at the moment.

@jondegenhardt
Copy link
Contributor Author

I saw an instance of this with LDC 1.5.0 and Ubuntu 16.04. Occurred after adding some code to one of my tools. Same behavior. I didn't investigate further, but instead tried switching to LDC 1.7.0, which uses LLVM 5.0.1. The issue did not occur. I don't know that there are any actions to take, apart from being aware that more cases may surface.

@jondegenhardt
Copy link
Contributor Author

Update: I tried building my tools with -static and LTO including druntime/phobos on Ubuntu 14.04 and a number of the recent LDC versions, including LDC 1.12.0. There were no successful builds. This is an informational note only, no actions needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants