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

2.064 std.uni release mode unit tests #594

Closed
dnadlinger opened this issue Mar 29, 2014 · 8 comments
Closed

2.064 std.uni release mode unit tests #594

dnadlinger opened this issue Mar 29, 2014 · 8 comments

Comments

@dnadlinger
Copy link
Member

On the 2.064 branch, the unit test for std.uni currently fails to build in release mode as the uni.o object from the Phobos library is linked in in addition to the unit test object file, leading to conflicting symbols.

The -why_load option of the OS X ld offers the following clue:

__D3std3uni159__T11TrieBuilderTbTwVi1114112TS3std3uni22__T9sliceBitsVm13Vm21Z9sliceBitsTS3std3uni21__T9sliceBitsVm9Vm13Z9sliceBitsTS3std3uni20__T9sliceBitsVm0Vm9Z9sliceBitsZ11TrieBuilder18__T8addValueVm2TbZ8addValueMFNaNbNebmZv forced load of /Users/aule/Build/Work/ldc2-llvm3.4-debug/lib/libphobos-ldc.a(uni.o)

Investigating…

@dnadlinger
Copy link
Member Author

Can you spot the difference?

_D3std3uni159__T11TrieBuilderTbTwVi1114112TS3std3uni22__T9sliceBitsVm13Vm21Z9sliceBitsTS3std3uni21__T9sliceBitsVm9Vm13Z9sliceBitsTS3std3uni20__T9sliceBitsVm0Vm9Z9sliceBitsZ11TrieBuilder18__T8addValueVm2TbZ8addValueMFNaNbNebmZv
vs.
_D3std3uni159__T11TrieBuilderTbTwVi1114112TS3std3uni22__T9sliceBitsVm13Vm21Z9sliceBitsTS3std3uni21__T9sliceBitsVi9Vi13Z9sliceBitsTS3std3uni20__T9sliceBitsVm0Vm9Z9sliceBitsZ11TrieBuilder18__T8addValueVm2TbZ8addValueMFNaNbNebmZv

The difference is that in the unit test build, sliceBits!(9, 13) is actually mangled as int parameters, whereas the symbol referenced by other Phobos modules is pure nothrow @trusted void std.uni.TrieBuilder!(bool, dchar, 1114112, std.uni.sliceBits!(13uL, 21uL).sliceBits, std.uni.sliceBits!(9uL, 13uL).sliceBits, std.uni.sliceBits!(0uL, 9uL).sliceBits).TrieBuilder.addValue!(2uL, bool).addValue(bool, ulong) with ulong parameters.

Unfortunately, I don't have the time to investigate this further right now.

@redstar
Copy link
Member

redstar commented May 8, 2014

I compared this to the output of dmd 2.064.2. dmd generates sliceBits!(9, 13) in debug and optimized build. That is a bit surprising.

@redstar
Copy link
Member

redstar commented May 8, 2014

Same with dmd 2.065.

As I am not an expert in D name mangling: what would be the expected mangling?
The definition is:

struct sliceBits(size_t from, size_t to) { .... }

My assumption was that the mangling uses the type of the type argument. Since size_t is an ulong on 64bit systems, I expected that the constant is cast to an ulong. But experiments reveal that the type of the constant is used: sliceBits(9, 13) is mangled as Vi9Vi13 (i for int) instead of Vm9Vm13 (m for ulong).

Looking at the unit tests I see only int constants used with sliceBits. For me, it looks like an inconsistency in dmd.

@dnadlinger
Copy link
Member Author

This might be related to https://issues.dlang.org/show_bug.cgi?id=3467, and a follow-up bug report I can't find right now. The behavior that integer template parameters would be mangled by the actual type of the literal, without being casted to the parameter types, used to be "by design". We convinced Walter that this is a bad idea, but maybe there are some remnants around still…

@redstar
Copy link
Member

redstar commented May 8, 2014

The bug report is a good hint. I added a comment about the name mangling.

@dnadlinger
Copy link
Member Author

See my comment there. The bug is supposedly fixed already for D2.

@redstar
Copy link
Member

redstar commented May 9, 2014

redstar added a commit to redstar/ldc that referenced this issue May 9, 2014
DMD always uses the value type for name mangling of templates. If the type is defined in the template
and the value type differs (e.g. parameter type is long and constant 4 (int) is used) then LDC got
confused about this fact. As a result, sometimes the parameter type and sometime the value type was used.

This commit changes the name mangling to use the parameter type, if possible. This is incompatible with
DMD but solves the issue. The related DMD error is https://issues.dlang.org/show_bug.cgi?id=12720
redstar added a commit to redstar/ldc that referenced this issue May 10, 2014
DMD always uses the value type for name mangling of templates. If the type is defined in the template
and the value type differs (e.g. parameter type is long and constant 4 (int) is used) then LDC got
confused about this fact. As a result, sometimes the parameter type and sometime the value type was used.

This commit changes the name mangling to use the parameter type, if possible. This is incompatible with
DMD but solves the issue. The related DMD error is https://issues.dlang.org/show_bug.cgi?id=12720
@redstar
Copy link
Member

redstar commented May 14, 2014

Fixed with commit e51529c in 0.13.0.

@redstar redstar closed this as completed May 14, 2014
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