ldc-developers / ldc

The LLVM-based D Compiler.
http://wiki.dlang.org/LDC
Other
1.21k stars 261 forks source link

Missing warning when installing imports into existing directory #2399

Open andrewbenton opened 6 years ago

andrewbenton commented 6 years ago

I'm using a freshly built and installed ldc v1.5.0 on Fedora 25 linux. The same source builds and runs successfully with dmd 2.076 and ldc v1.4.0

Minimal example:

/** min_time.d **/
import std.datetime;
import std.stdio;

void main()
{
    auto time = Clock.currTime;
    time.writeln;
}

Attempting to compile as ldc2 min_time.d yields:

min_time.o: In function `_Dmain':
min_time.d:(.text._Dmain[_Dmain]+0x5): undefined reference to `_D3std8datetime9LocalTime6opCallFNaNbNeZyC3std8datetime9LocalTime'
min_time.o: In function `_D3std8datetime5Clock37__T8currTimeVE4core4time9ClockTypei0Z8currTimeFNfyC3std8datetime8TimeZoneZS3std8datetime7SysTime':
min_time.d:(.text._D3std8datetime5Clock37__T8currTimeVE4core4time9ClockTypei0Z8currTimeFNfyC3std8datetime8TimeZoneZS3std8datetime7SysTime[_D3std8datetime5Clock37__T8currTimeVE4core4time9ClockTypei0Z8currTimeFNfyC3std8datetime8TimeZoneZS3std8datetime7SysTime]+0x2e): undefined reference to `_D3std8datetime7SysTime6__ctorMFNaNbNcNflyC3std8datetime8TimeZoneZS3std8datetime7SysTime'
min_time.o: In function `_D3std6format79__T12formatObjectTS3std5stdio4File17LockingTextWriterTS3std8datetime7SysTimeTaZ12formatObjectFNfKS3std5stdio4File17LockingTextWriterKS3std8datetime7SysTimeKxS3std6format18__T10FormatSpecTaZ10FormatSpecZv':
min_time.d:(.text._D3std6format79__T12formatObjectTS3std5stdio4File17LockingTextWriterTS3std8datetime7SysTimeTaZ12formatObjectFNfKS3std5stdio4File17LockingTextWriterKS3std8datetime7SysTimeKxS3std6format18__T10FormatSpecTaZ10FormatSpecZv[_D3std6format79__T12formatObjectTS3std5stdio4File17LockingTextWriterTS3std8datetime7SysTimeTaZ12formatObjectFNfKS3std5stdio4File17LockingTextWriterKS3std8datetime7SysTimeKxS3std6format18__T10FormatSpecTaZ10FormatSpecZv]+0x12): undefined reference to `_D3std8datetime7SysTime8toStringMxFNbNfZAya'
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
kinke commented 6 years ago

It obviously works with the official release package. std.datetime was refactored/split up as a package in 2.075 IIRC, so I'm guessing you're not using the correct Phobos version. Are your git submodules up to date?

kinke commented 6 years ago

In particular, there's no std.datetime.Clock anymore; that's std.datetime.systime.Clock now. So your libs may be okay, but your -I imports seem to be of an older version.

andrewbenton commented 6 years ago

They're up to date. My command sequence is as follows:

$ git clone --recursive git@github.com:ldc-developers/ldc
$ cd ldc
$ git checkout v1.5.0
$ git submodule update --init --recursive
$ mkdir build
$ cd build
$ cmake ..
$ make -j4
$ sudo make install
andrewbenton commented 6 years ago

So this is interesting, the install from v1.4.0 -> v1.5.0 didn't overwrite the /usr/include/d/std/datetime.d and replace it with the directory version. Manually removing /usr/include/d and re-running the sudo make install command worked. So the existing datetime.d still existed there post-install, but no error was reported when trying to install the v1.5.0 sources over it. I'll double check that for repeatability.

kinke commented 6 years ago

I had similar issues in the past myself. The files are just copied over, so old obsolete ones are kept (as potential 3rd-party ones too), and apparently the frontend prefers single-file modules over packages. We should probably at least warn about an existing import dir during install.

kinke commented 6 years ago

[The front-end should probably error out in case there are conflicting foo.d and foo/package.d.]