Skip to content

Commit 1362534

Browse files
committed
Merge branch 'master' into release-0.16.0
2 parents 7dc21f0 + 41eaa5b commit 1362534

File tree

13 files changed

+104
-40
lines changed

13 files changed

+104
-40
lines changed

.travis.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ after_success:
6666
fi
6767

6868
notifications:
69-
# Temporarily disabled due to time limit problems.
70-
# email:
71-
# recipients:
72-
73-
# on_success: never
74-
# on_failure: change
69+
email:
70+
recipients:
71+
72+
on_success: never
73+
on_failure: change
7574
irc:
7675
channels:
7776
- "irc.freenode.org#ldc"

appveyor.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ matrix:
2626
# scripts that are called at very beginning, before repo cloning
2727
init:
2828
- git config --global core.autocrlf input
29-
- ren "c:\Program Files (x86)\Windows Kits\10\include\wdf" 00wdf
3029
- call "c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
3130
# Print environment info
3231
- set
@@ -100,7 +99,7 @@ build_script:
10099
- cd ninja-ldc
101100
- cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=c:\projects\ldc-x64 -DLLVM_ROOT_DIR=c:/projects/llvm-x64 -DLIBCONFIG_INCLUDE_DIR=c:/projects/libconfig/lib -DLIBCONFIG_LIBRARY=c:/projects/libconfig/lib/x64/ReleaseStatic/libconfig.lib ..\ldc
102101
# Work around LDC issue #930
103-
- ps: (gc build.ninja).replace('runtime/std/string-unittest-debug.obj -w -d -g -unittest', 'runtime/std/string-unittest-debug.obj -w -d -unittest') | sc build.ninja
102+
- ps: (gc build.ninja).replace('runtime/std/string-unittest-debug.obj -w -d -g -link-debuglib -unittest', 'runtime/std/string-unittest-debug.obj -w -d -link-debuglib -unittest') | sc build.ninja
104103
# Build LDC, druntime and phobos
105104
- ninja -j2
106105

@@ -110,12 +109,13 @@ after_build:
110109
If ($Env:APPVEYOR_JOB_CONFIG -eq 'Debug') {
111110
echo 'Preparing artifact...'
112111
cd c:\projects\ninja-ldc
113-
ninja install
112+
ninja install > $null
114113
copy bin\ldc2.pdb ..\ldc-x64\bin
115114
cd ..\ldc-x64
116-
7z a ..\ldc-x64.7z * > $null
115+
$artifactFilename = "LDC-Win64-master-$Env:APPVEYOR_BUILD_NUMBER.7z"
116+
7z a "..\$artifactFilename" * > $null
117117
cd ..
118-
Push-AppveyorArtifact ldc-x64.7z
118+
Push-AppveyorArtifact $artifactFilename
119119
}
120120
121121
#---------------------------------#
@@ -146,11 +146,11 @@ test_script:
146146

147147
deploy:
148148
release: 'LDC Win64 master'
149-
description: 'Rolling release based on latest successful Win64 CI build from master branch'
149+
description: "Latest successful Win64 CI builds of branch 'master'"
150150
provider: GitHub
151151
auth_token:
152152
secure: qnbD8agL9mr0SFvy/sMkR2E29oQQ427T5zYwVVZkjRS3IZ361tG+9jlSiyEkyULy
153-
artifact: ldc-x64.7z
153+
artifact: LDC-Win64-master-$(APPVEYOR_BUILD_NUMBER).7z
154154
draft: true
155155
prerelease: true
156156
on:

driver/main.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,18 @@ static cl::list<std::string, StringsAdapter> importPaths("I",
9090
cl::Prefix);
9191

9292
static cl::opt<std::string> defaultLib("defaultlib",
93-
cl::desc("Default libraries for non-debug-info build (overrides previous)"),
93+
cl::desc("Default libraries to link with (overrides previous)"),
9494
cl::value_desc("lib1,lib2,..."),
9595
cl::ZeroOrMore);
9696

9797
static cl::opt<std::string> debugLib("debuglib",
98-
cl::desc("Default libraries for debug info build (overrides previous)"),
98+
cl::desc("Debug versions of default libraries (overrides previous)"),
9999
cl::value_desc("lib1,lib2,..."),
100100
cl::ZeroOrMore);
101101

102+
static cl::opt<bool> linkDebugLib("link-debuglib",
103+
cl::desc("Link with libraries specified in -debuglib, not -defaultlib"),
104+
cl::ZeroOrMore);
102105

103106
#if LDC_LLVM_VER < 304
104107
namespace llvm {
@@ -401,8 +404,16 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
401404
sourceFiles.reserve(fileList.size());
402405
typedef std::vector<std::string>::iterator It;
403406
for(It I = fileList.begin(), E = fileList.end(); I != E; ++I)
407+
{
404408
if (!I->empty())
405-
sourceFiles.push(mem.xstrdup(I->c_str()));
409+
{
410+
char* copy = mem.xstrdup(I->c_str());
411+
#ifdef _WIN32
412+
std::replace(copy, copy + I->length(), '/', '\\');
413+
#endif
414+
sourceFiles.push(copy);
415+
}
416+
}
406417

407418
if (noDefaultLib)
408419
{
@@ -413,8 +424,7 @@ static void parseCommandLine(int argc, char **argv, Strings &sourceFiles, bool &
413424
else
414425
{
415426
// Parse comma-separated default library list.
416-
std::stringstream libNames(
417-
global.params.symdebug ? debugLib : defaultLib);
427+
std::stringstream libNames(linkDebugLib ? debugLib : defaultLib);
418428
while (libNames.good())
419429
{
420430
std::string lib;
@@ -1077,7 +1087,7 @@ int main(int argc, char **argv)
10771087
const char *ext;
10781088
const char *name;
10791089

1080-
const char *p = static_cast<const char *>(files.data[i]);
1090+
const char *p = files.data[i];
10811091

10821092
p = FileName::name(p); // strip path
10831093
ext = FileName::ext(p);
@@ -1176,7 +1186,7 @@ int main(int argc, char **argv)
11761186
}
11771187

11781188
id = Identifier::idPool(name);
1179-
Module *m = new Module(static_cast<const char *>(files.data[i]), id, global.params.doDocComments, global.params.doHdrGeneration);
1189+
Module *m = new Module(files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration);
11801190
modules.push(m);
11811191
}
11821192

gen/abi-aarch64.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ struct AArch64TargetABI : TargetABI
125125
// pass a void* pointer to the actual __va_list struct to LLVM's va_arg intrinsic
126126
return DtoLoad(pAp);
127127
}
128+
129+
Type* vaListType() {
130+
// We need to pass the actual va_list type for correct mangling. Simply
131+
// using TypeIdentifier here is a bit wonky but works, as long as the name
132+
// is actually available in the scope (this is what DMD does, so if a better
133+
// solution is found there, this should be adapted).
134+
return (new TypeIdentifier(Loc(),
135+
Identifier::idPool("__va_list_tag")))->pointerTo();
136+
}
128137
};
129138

130139
// The public getter for abi.cpp

gen/abi-x86.cpp

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
//===----------------------------------------------------------------------===//
99

1010
#include "gen/llvm.h"
11+
#include "id.h"
1112
#include "mars.h"
1213
#include "gen/abi-generic.h"
1314
#include "gen/abi.h"
@@ -70,6 +71,7 @@ struct X86TargetABI : TargetABI
7071
}
7172
}
7273

74+
private:
7375
bool returnOSXStructInArg(TypeStruct* t)
7476
{
7577
// https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/LowLevelABI/Mac_OS_X_ABI_Function_Calls.pdf
@@ -86,6 +88,20 @@ struct X86TargetABI : TargetABI
8688
return !t->sym->isPOD() || (sz != 1 && sz != 2 && sz != 4 && sz != 8);
8789
}
8890

91+
bool isMagicCLong(Type *t)
92+
{
93+
// The frontend has magic structs to express the variable-sized C types
94+
// for C++ mangling purposes. We need to pass them like integers, not
95+
// on the stack.
96+
97+
Type * const bt = t->toBasetype();
98+
if (bt->ty != Tstruct) return false;
99+
100+
Identifier *id = static_cast<TypeStruct *>(bt)->sym->ident;
101+
return (id == Id::__c_long) || (id == Id::__c_ulong);
102+
}
103+
104+
public:
89105
bool returnInArg(TypeFunction* tf)
90106
{
91107
if (tf->isref)
@@ -103,6 +119,8 @@ struct X86TargetABI : TargetABI
103119
// as well as structs (except for some OSX cases).
104120
else
105121
{
122+
if (isMagicCLong(rt)) return false;
123+
106124
if (rt->ty == Tstruct)
107125
{
108126
return !isOSX || returnOSXStructInArg((TypeStruct*)rt);
@@ -193,9 +211,10 @@ struct X86TargetABI : TargetABI
193211
{
194212
// RETURN VALUE
195213

196-
// cfloat -> i64
197-
if (tf->next->toBasetype() == Type::tcomplex32)
214+
if ((!fty.ret->byref && isMagicCLong(tf->next)) ||
215+
tf->next->toBasetype() == Type::tcomplex32)
198216
{
217+
// __c_long -> i32, cfloat -> i64
199218
fty.ret->rewrite = &integerRewrite;
200219
fty.ret->ltype = integerRewrite.type(fty.ret->type, fty.ret->ltype);
201220
}
@@ -212,12 +231,14 @@ struct X86TargetABI : TargetABI
212231
fty.ret->ltype = integerRewrite.type(fty.ret->type, fty.ret->ltype);
213232
}
214233
}
234+
215235
// IMPLICIT PARAMETERS
216236

217237
// EXPLICIT PARAMETERS
218238

219239
// Clang does not pass empty structs, while it seems that GCC does,
220-
// at least on Linux x86.
240+
// at least on Linux x86. We don't know whether the C compiler will
241+
// be Clang or GCC, so just assume Clang on OS X and G++ on Linux.
221242
if (isOSX)
222243
{
223244
size_t i = 0;
@@ -240,6 +261,18 @@ struct X86TargetABI : TargetABI
240261
++i;
241262
}
242263
}
264+
265+
for (size_t i = 0; i < fty.args.size(); ++i)
266+
{
267+
IrFuncTyArg *arg = fty.args[i];
268+
if (!arg->byref && isMagicCLong(arg->type))
269+
{
270+
arg->rewrite = &integerRewrite;
271+
arg->ltype = integerRewrite.type(arg->type, arg->ltype);
272+
arg->byref = false;
273+
arg->attrs.clear();
274+
}
275+
}
243276
}
244277
}
245278
};

gen/arrays.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -441,21 +441,28 @@ LLConstant* DtoConstArrayInitializer(ArrayInitializer* arrinit)
441441
if (global.errors)
442442
fatal();
443443

444-
// fill out any null entries still left with default values
445-
446-
// element default initializer
447-
LLConstant* defelem = DtoConstExpInit(arrinit->loc, elemty, elemty->defaultInit(arrinit->loc));
448-
bool mismatch2 = (defelem->getType() != llelemty);
444+
// Fill out any null entries still left with default values.
449445

446+
// Element default initializer. Compute lazily to be able to avoid infinite
447+
// recursion for types with members that are default initialized to empty
448+
// arrays of themselves.
449+
LLConstant* elemDefaultInit = NULL;
450450
for (size_t i = 0; i < arrlen; i++)
451451
{
452452
if (initvals[i] != NULL)
453453
continue;
454454

455-
initvals[i] = defelem;
455+
if (!elemDefaultInit)
456+
{
457+
elemDefaultInit = DtoConstExpInit(arrinit->loc, elemty,
458+
elemty->defaultInit(arrinit->loc));
459+
if (elemDefaultInit->getType() != llelemty)
460+
{
461+
mismatch = true;
462+
}
463+
}
456464

457-
if (mismatch2)
458-
mismatch = true;
465+
initvals[i] = elemDefaultInit;
459466
}
460467

461468
LLConstant* constarr;

gen/dibuilder.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,9 +841,10 @@ void ldc::DIBuilder::EmitStopPoint(Loc& loc)
841841
// (line 0), then we can just ignore it (see GitHub issue #998 for why we
842842
// cannot do this in all cases).
843843
if (!loc.linnum &&
844-
!IR->ir->getCurrentDebugLocation()
845-
#if LDC_LLVM_VER < 307
846-
.isUnknown()
844+
#if LDC_LLVM_VER >= 307
845+
IR->ir->getCurrentDebugLocation()
846+
#else
847+
!IR->ir->getCurrentDebugLocation().isUnknown()
847848
#endif
848849
)
849850
return;

gen/programs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ static std::string getProgram(const char *name, const cl::opt<std::string> &opt,
7070

7171
std::string getGcc()
7272
{
73+
#if defined(__FreeBSD__) && __FreeBSD__ >= 10
74+
// Default compiler on FreeBSD 10 is clang
75+
return getProgram("clang", gcc, "CC");
76+
#else
7377
return getProgram("gcc", gcc, "CC");
78+
#endif
7479
}
7580

7681
std::string getArchiver()

runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ set(BUILD_BC_LIBS OFF CACHE BOOL
1313
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/include/d CACHE PATH "Path to install D modules to")
1414
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Whether to build the runtime as a shared library")
1515
set(D_FLAGS -w;-d CACHE STRING "Runtime build flags, separated by ;")
16-
set(D_FLAGS_DEBUG -g CACHE STRING "Runtime build flags (debug libraries), separated by ;")
16+
set(D_FLAGS_DEBUG -g;-link-debuglib CACHE STRING "Runtime build flags (debug libraries), separated by ;")
1717
set(D_FLAGS_RELEASE -O3;-release CACHE STRING "Runtime build flags (release libraries), separated by ;")
1818
if(MSVC)
1919
set(LINK_WITH_MSVCRT ON CACHE BOOL "Link with MSVCRT.lib (DLL) instead of LIBCMT.lib (static)")

0 commit comments

Comments
 (0)