Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions setmscver.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ cl /nologo /EP ver.c > ver_raw.txt
findstr /v /r /c:"^$" "ver_raw.txt" > "ver.txt"
set /P _MSC_VER=< ver.txt
echo set _MSC_VER=%_MSC_VER%
if exist cflags.txt del /q cflags.txt
if exist dflags.txt del /q dflags.txt
if exist add_tests.txt del /q add_tests.txt
if %_MSC_VER% GTR 1900 echo /std:c++17 > cflags.txt
if %_MSC_VER% GTR 1900 echo -extern-std=c++17 > dflags.txt
if %_MSC_VER% GTR 1900 echo string_view > add_tests.txt
del ver.c ver_raw.txt
5 changes: 4 additions & 1 deletion src/core/stdcpp/new_.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import core.stdcpp.exception : exception;
@nogc:

// TODO: this really should come from __traits(getTargetInfo, "defaultNewAlignment")
enum size_t __STDCPP_DEFAULT_NEW_ALIGNMENT__ = 16;
version (D_LP64)
enum size_t __STDCPP_DEFAULT_NEW_ALIGNMENT__ = 16;
else
enum size_t __STDCPP_DEFAULT_NEW_ALIGNMENT__ = 8;

extern (C++, "std")
{
Expand Down
4 changes: 2 additions & 2 deletions test/stdcpp/src/new_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ extern(C++) bool hasAlignedNew();
unittest
{
// test the magic numbers are consistent between C++ and D
assert(hasAlignedNew() == __cpp_aligned_new);
assert(hasAlignedNew() == !!__cpp_aligned_new, "__cpp_aligned_new does not match C++ compiler");
static if (__cpp_aligned_new)
assert(defaultAlignment() == __STDCPP_DEFAULT_NEW_ALIGNMENT__);
assert(defaultAlignment() == __STDCPP_DEFAULT_NEW_ALIGNMENT__, "__STDCPP_DEFAULT_NEW_ALIGNMENT__ does not match C++ compiler");

// alloc in C++, delete in D
MyStruct s = cpp_new();
Expand Down
25 changes: 15 additions & 10 deletions test/stdcpp/win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@ MODEL=64
DRUNTIMELIB=druntime64.lib
CC=cl

_MSC_VER = $(file < ..\..\ver.txt)
TESTS=array allocator new string vector

TESTS= array allocator new string vector
_MSC_VER=$(file < ..\..\ver.txt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be very surprised if this works with Digital Mars make.
AFAICT including a file only works with a line like this (from druntime/win64.mak):

$(mak\COPY)

This reads a single assignment from the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you expect doesn't work?
This does work... the tests all pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for -version=_MSC_VER_xxxx in the CI logs. That value is read from this line at your comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surprising. $(file < MAK\COPY) is empty for me. _MSC_VER=$(..\..\ver.txt) would work.

I suspect the auto-tester is not using Digital Mars make here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran the same script locally... It works, and the tests invoke with all proper args... How are you running it?
auto-tester and appveyor both seem to work... My local machine too. I'm surprised...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, check the CI logs. The msc ver and the cflags and dflags are supplied correctly. It also did build string_view, which is pulled the same way...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR passes for me locally, too. I'm confused ;-)

ADD_CFLAGS=$(file < ..\..\cflags.txt)
ADD_DFLAGS=$(file < ..\..\dflags.txt)
ADD_TESTS=$(file < ..\..\add_tests.txt)

TESTS=$(TESTS) $(ADD_TESTS)

test: $(TESTS)

$(TESTS):
"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MT
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=libcmt test\stdcpp\src\$@_test.d $@_cpp.obj
"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MT $(ADD_CFLAGS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this also works directly if there is a file with the name ADD_CFLAGS that has the settings, see https://github.com/DigitalMars/Compiler/blob/1dbd3e3381c8f7f7ab2e35214dcd63455ae38c29/dm/src/make/dmake.d#L1130.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any documentation to that effect in the scant docs.
That would be highly unusual though I think... I kinda like that way I've written it makes it terribly clear what mischief is at play.

"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=libcmt $(ADD_DFLAGS) test\stdcpp\src\$@_test.d $@_cpp.obj
$@.exe
del $@.exe $@.obj $@_cpp.obj

"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MD
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=msvcrt test\stdcpp\src\$@_test.d $@_cpp.obj
"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MD $(ADD_CFLAGS)
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=msvcrt $(ADD_DFLAGS) test\stdcpp\src\$@_test.d $@_cpp.obj
$@.exe
del $@.exe $@.obj $@_cpp.obj

"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MTd
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=libcmtd test\stdcpp\src\$@_test.d $@_cpp.obj
"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MTd $(ADD_CFLAGS)
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=libcmtd $(ADD_DFLAGS) test\stdcpp\src\$@_test.d $@_cpp.obj
$@.exe
del $@.exe $@.obj $@_cpp.obj

"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MDd
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=msvcrtd test\stdcpp\src\$@_test.d $@_cpp.obj
"$(CC)" -c /Fo$@_cpp.obj test\stdcpp\src\$@.cpp /EHsc /MDd $(ADD_CFLAGS)
"$(DMD)" -of=$@.exe -m$(MODEL) -conf= -Isrc -defaultlib=$(DRUNTIMELIB) -main -unittest -version=_MSC_VER_$(_MSC_VER) -mscrtlib=msvcrtd $(ADD_DFLAGS) test\stdcpp\src\$@_test.d $@_cpp.obj
$@.exe
del $@.exe $@.obj $@_cpp.obj