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

Runtime conflict with druntime #47

Closed
jacob-carlborg opened this issue Dec 12, 2012 · 8 comments
Closed

Runtime conflict with druntime #47

jacob-carlborg opened this issue Dec 12, 2012 · 8 comments

Comments

@jacob-carlborg
Copy link
Contributor

There are some conflicts between the functionality in tango.core.Runtime and core.runtime. For example, the unit test runner in Tango seems to override the one in druntime.

BTW why are some parts of the Tango runtime left, like:

tango.core. -

  • Runtime
  • Thread
  • Vararg
  • Memory
@SiegeLord
Copy link
Owner

Those are backwards compatibility modules.

I am confused about the nature of the bug here... is this an issue of using both in the same program? Or the Tango one not working at all?

@jacob-carlborg
Copy link
Contributor Author

The issue is the following:

module main;
import std.stdio;

unittest {
    writeln("foo");
}

void main () { }
$ dmd main.d -unittest -L-ltango-d2 && ./main

The expected output is "foo", but there is no output. As soon as I link with Tango it won't run the unit tests. Note that I don't even need to use Tango in the application, I just need to link with Tango. I think the issue is tango.core.Runtime.runModuleUnitTests. druntime contains a function with the exact same name. Since both the one in Tango and the one in druntime is declared as extern(C) they will have the same name. I think the one in Tango overrides the on in druntime.

The version of runModuleUnitTests in Tango would work fine, expect that ModuleInfo.unitTest is a method that returns a function pointer these days. If you look a the implementation of runModuleUnitTests in Tango you can see that it calls m.unitTest() to run a given unit test block. Due to how properties work in D this will only call the unitTest method and not the function pointer returning it.

I think these modules should be removed from Tango, they're part of the runtime, which druntime implements now. If these exist along side with the ones in druntime Tango won't be compatible with druntime and we have the same problem again as we did with D1.

@SiegeLord
Copy link
Owner

I can't reproduce this behavior (the code you pasted runs just fine for me). What OS is this?

I'll see what I can do about the mismatched function types. I'd rather not alias tango.core.Runtime with core.runtime since Tango's version of that module has features missing in druntime... I'll see if I can combine them somehow.

@jacob-carlborg
Copy link
Contributor Author

I can't reproduce this behavior (the code you pasted runs just fine for me). What OS is this?

Mac OS X.

I'll see what I can do about the mismatched function types. I'd rather not alias tango.core.Runtime with core.runtime since Tango's version of that module has features missing in druntime... I'll see if I can combine them somehow.

That would be nice.

@jacob-carlborg
Copy link
Contributor Author

The command DMD uses to link is:

gcc main.o -o main -m64 -ltango -L/Users/jacob/.dvm/compilers/dmd-2.060/bin/../lib -lphobos2 -lpthread -lm

If I move -ltango to come after -lphobos2 everything works as expected.

@jacob-carlborg
Copy link
Contributor Author

A guess, remove extern(C) from runModuleUnitTests and it will work.

@SiegeLord
Copy link
Owner

Could you try it now, now that 6a29012 is committed?

@jacob-carlborg
Copy link
Contributor Author

Thanks that works. Fixed in 6a29012

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