Skip to content

Commit

Permalink
Merge branch 'master' into merge-2.074
Browse files Browse the repository at this point in the history
Conflicts:
	runtime/druntime
	runtime/phobos
  • Loading branch information
kinke committed Jul 27, 2017
2 parents cd45257 + 5d86c1f commit 66241ab
Show file tree
Hide file tree
Showing 58 changed files with 7,253 additions and 318 deletions.
14 changes: 4 additions & 10 deletions .circleci/config.yml
Expand Up @@ -55,27 +55,21 @@ jobs:
bin/ldc2 -version
cd ..
- run:
name: Build LDC
name: Build LDC and stdlib unittest runners
command: |
export HOST_LDMD=$PWD/bootstrap/bin/ldmd2
mkdir build
cd build
cmake -G Ninja -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON -DD_COMPILER=$HOST_LDMD ..
ninja -j3
ninja -j3 all all-test-runners
bin/ldc2 -version
cd ..
- run:
name: Compile stdlib unittests
command: |
cd build
ninja -j3 phobos2-ldc-unittest-debug phobos2-ldc-unittest druntime-ldc-unittest-debug druntime-ldc-unittest
ninja -j3 phobos2-ldc-unittest-debug-shared phobos2-ldc-unittest-shared druntime-ldc-unittest-debug-shared druntime-ldc-unittest-shared
- run:
name: Run LDC unittests
name: Build and run LDC D unittests
command: cd build && ctest --output-on-failure -R ldc2-unittest
when: always
- run:
name: Run LIT tests
name: Run LIT testsuite
command: cd build && ctest -V -R lit-tests
when: always
- run:
Expand Down
11 changes: 3 additions & 8 deletions .travis.yml
Expand Up @@ -84,23 +84,18 @@ install:

script:
- cmake -G Ninja -DLLVM_CONFIG=$(which ${LLVM_CONFIG}) -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON $OPTS .
- ninja -j3
# Build LDC and stdlib unittest runners.
- ninja -j3 all all-test-runners
# Output some environment info, plus make sure we only run the test suite
# if we could actually build the executable.
- bin/ldc2 -version || exit 1
# Build Phobos & druntime unittest modules.
- ninja -j3 phobos2-ldc-unittest-debug phobos2-ldc-unittest druntime-ldc-unittest-debug druntime-ldc-unittest
-
if [[ ! "${OPTS}" == *-DBUILD_SHARED_LIBS* ]]; then
ninja -j3 phobos2-ldc-unittest-debug-shared phobos2-ldc-unittest-shared druntime-ldc-unittest-debug-shared druntime-ldc-unittest-shared;
fi
# Build and run LDC D unittests.
- ctest --output-on-failure -R "ldc2-unittest"
# Run LIT testsuite.
- ctest -V -R "lit-tests"
# Run DMD testsuite.
- DMD_TESTSUITE_MAKE_ARGS=-j3 ctest -V -R "dmd-testsuite"
# Link and run Phobos & druntime unittest runners.
# Run stdlib unittests.
- ctest -j3 --output-on-failure -E "dmd-testsuite|lit-tests|ldc2-unittest"

after_success:
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Expand Up @@ -704,7 +704,7 @@ build_d_executable(
"${LDMD_D_SOURCE_FILES}"
"$<TARGET_LINKER_FILE:LDMD_CXX_LIB>"
"${LDMD_D_SOURCE_FILES}"
"LDMD_CXX_LIB;${LDC_LIB}"
"LDMD_CXX_LIB"
)

#
Expand Down Expand Up @@ -754,6 +754,7 @@ function(copy_compilerrt_lib llvm_lib_name ldc_lib_name fixup_dylib)
if (fixup_dylib)
execute_process(COMMAND install_name_tool -id @rpath/${ldc_lib_name} ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/${ldc_lib_name})
endif()
install(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/${ldc_lib_name} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
else()
message(STATUS "Not found: ${llvm_lib_path}")
endif()
Expand All @@ -771,6 +772,7 @@ if (LDC_INSTALL_LLVM_RUNTIME_LIBS)
message(STATUS "Copying libFuzzer library: ${LLVM_LIBFUZZER_PATH} --> libFuzzer.a")
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX})
configure_file(${LLVM_LIBFUZZER_PATH} ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libFuzzer.a COPYONLY)
install(FILES ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX}/libFuzzer.a DESTINATION ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
else()
message(STATUS "Not found: ${LLVM_LIBFUZZER_PATH}")
endif()
Expand Down Expand Up @@ -817,6 +819,9 @@ add_subdirectory(tests)

install(PROGRAMS ${LDC_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
install(PROGRAMS ${LDMD_EXE_FULL} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
if(NOT CMAKE_INSTALL_PREFIX STREQUAL "/usr")
install(PROGRAMS ${PROJECT_BINARY_DIR}/bin/build-ldc-runtime.sh DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif()
if(${BUILD_SHARED})
# For now, only install libldc if explicitly building the shared library.
# While it might theoretically be possible to use LDC as a static library
Expand Down
26 changes: 10 additions & 16 deletions appveyor.yml
Expand Up @@ -90,9 +90,9 @@ install:
# Download & extract a pre-built LLVM (CMAKE_BUILD_TYPE=Release, LLVM_ENABLE_ASSERTIONS=ON)
- ps: |
If ($Env:APPVEYOR_JOB_ARCH -eq 'x64') {
appveyor DownloadFile 'https://dl.dropboxusercontent.com/s/phhwfs01jpcx74l/LLVM-3.9.1-x64-MT.7z?dl=0' -FileName llvm-x64.7z
appveyor DownloadFile 'https://dl.dropboxusercontent.com/s/nxw73qdy4dqs23p/LLVM-4.0.1-x64.7z?dl=0' -FileName llvm-x64.7z
} Else {
appveyor DownloadFile 'https://dl.dropboxusercontent.com/s/cx5k09yablneyv3/LLVM-3.9.1-x86-MT.7z?dl=0' -FileName llvm-x86.7z
appveyor DownloadFile 'https://dl.dropboxusercontent.com/s/probihgpillkpuk/LLVM-4.0.1-x86.7z?dl=0' -FileName llvm-x86.7z
}
- md llvm-%APPVEYOR_JOB_ARCH%
- cd llvm-%APPVEYOR_JOB_ARCH%
Expand Down Expand Up @@ -120,8 +120,8 @@ build_script:
- cd ninja-ldc
- if "%APPVEYOR_JOB_ARCH%"=="x64" ( cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=c:\projects\ldc-x64 -DLLVM_ROOT_DIR=c:/projects/llvm-x64 ..\ldc )
- if "%APPVEYOR_JOB_ARCH%"=="x86" ( cmake -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=c:\projects\ldc-x86 -DLLVM_ROOT_DIR=c:/projects/llvm-x86 ..\ldc )
# Build LDC, druntime and phobos
- ninja -j2
# Build LDC and stdlib unittest runners
- ninja -j2 all all-test-runners

after_build:
# install LDC, compress & publish as artifact
Expand Down Expand Up @@ -179,21 +179,15 @@ after_build:
test_script:
- cd c:\projects\ninja-ldc
- bin\ldc2 -version
# Compile, link & execute a hello-world program
- ps: 'echo "import std.stdio; void main() { writeln(""Hello world!""); }" > hello.d'
- bin\ldc2 hello.d
- hello.exe
# Compile the druntime & phobos unit tests
- ninja -j2 druntime-ldc-unittest-debug phobos2-ldc-unittest-debug druntime-ldc-unittest phobos2-ldc-unittest
# Run dmd-testsuite
# Build and run LDC D unittests
- ctest --output-on-failure -R "ldc2-unittest"
# Run LIT testsuite
- ctest -V -R "lit-tests"
# Run DMD testsuite
- if "%APPVEYOR_JOB_ARCH%"=="x64" ( set OS=Win_64) else ( set OS=Win_32)
- set DMD_TESTSUITE_MAKE_ARGS=-j2
- ctest -V -R "dmd-testsuite"
# Run lit testsuite
- ctest -V -R "lit-tests"
# Build and run LDC D unittests
- ctest --output-on-failure -R "ldc2-unittest"
# Link and run Phobos & druntime unittest runners
# Run stdlib unittests
- ctest -j2 --output-on-failure -E "dmd-testsuite|lit-tests|ldc2-unittest"

#---------------------------------#
Expand Down
21 changes: 8 additions & 13 deletions ddmd/aggregate.d
Expand Up @@ -614,22 +614,23 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
*
* nextoffset: next location in aggregate
* memsize: size of member
* memalignsize: size of member for alignment purposes
* memalignsize: natural alignment of member
* alignment: alignment in effect for this member
* paggsize: size of aggregate (updated)
* paggalignsize: size of aggregate for alignment purposes (updated)
* paggalignsize: alignment of aggregate (updated)
* isunion: the aggregate is a union
*/
static uint placeField(uint* nextoffset, uint memsize, uint memalignsize,
structalign_t alignment, uint* paggsize, uint* paggalignsize, bool isunion)
{
uint ofs = *nextoffset;

const uint actualAlignment =
alignment == STRUCTALIGN_DEFAULT ? memalignsize : alignment;

// Ensure no overflow
bool overflow;
const sz = addu(memsize,
alignment == STRUCTALIGN_DEFAULT ? memalignsize : alignment,
overflow);
const sz = addu(memsize, actualAlignment, overflow);
const sum = addu(ofs, sz, overflow);
if (overflow) assert(0);

Expand All @@ -641,14 +642,8 @@ extern (C++) abstract class AggregateDeclaration : ScopeDsymbol
if (!isunion)
*nextoffset = ofs;

if (alignment != STRUCTALIGN_DEFAULT)
{
if (memalignsize < alignment)
memalignsize = alignment;
}

if (*paggalignsize < memalignsize)
*paggalignsize = memalignsize;
if (*paggalignsize < actualAlignment)
*paggalignsize = actualAlignment;

return memoffset;
}
Expand Down
18 changes: 15 additions & 3 deletions ddmd/arrayop.d
Expand Up @@ -203,9 +203,12 @@ extern (C++) Expression arrayOp(BinExp e, Scope* sc)

version(IN_LLVM)
{
auto arrayfuncs = sc._module.arrayfuncs;
FuncDeclaration* pFd = cast(void*)ident in sc._module.arrayfuncs;
}
else
{
FuncDeclaration* pFd = cast(void*)ident in arrayfuncs;
}
FuncDeclaration* pFd = cast(void*)ident in arrayfuncs;
FuncDeclaration fd;
if (pFd)
fd = *pFd;
Expand All @@ -226,7 +229,16 @@ extern (C++) Expression arrayOp(BinExp e, Scope* sc)
}

if (!pFd)
arrayfuncs[cast(void*)ident] = fd;
{
version(IN_LLVM)
{
sc._module.arrayfuncs[cast(void*)ident] = fd;
}
else
{
arrayfuncs[cast(void*)ident] = fd;
}
}

Expression ev = new VarExp(e.loc, fd);
Expression ec = new CallExp(e.loc, ev, arguments);
Expand Down
3 changes: 3 additions & 0 deletions driver/cl_options.cpp
Expand Up @@ -578,12 +578,15 @@ void hideLLVMOptions() {
"mno-fixup", "mno-ldc1-sdc1", "mno-pairing", "mwarn-missing-parenthesis",
"mwarn-noncontigious-register", "mwarn-sign-mismatch", "nvptx-sched4reg",
"no-discriminators", "objc-arc-annotation-target-identifier",
"polly-dump-after", "polly-dump-after-file", "polly-dump-before",
"polly-dump-before-file",
"pre-RA-sched", "print-after-all", "print-before-all",
"print-machineinstrs", "profile-estimator-loop-weight",
"profile-estimator-loop-weight", "profile-file", "profile-info-file",
"profile-verifier-noassert", "r600-ir-structurize", "rdf-dump",
"rdf-limit", "regalloc", "rewrite-map-file", "rng-seed",
"sample-profile-max-propagate-iterations", "shrink-wrap", "spiller",
"spirv-debug", "spirv-erase-cl-md", "spirv-mem2reg", "spvbool-validate",
"stackmap-version", "stats", "strip-debug", "struct-path-tbaa",
"time-passes", "unit-at-a-time", "verify-debug-info", "verify-dom-info",
"verify-loop-info", "verify-machine-dom-info", "verify-regalloc",
Expand Down
22 changes: 11 additions & 11 deletions driver/configfile.cpp
Expand Up @@ -175,17 +175,17 @@ bool ConfigFile::read(const char *explicitConfFile, const char *section) {
// explicitly provided by user in command line?
if (explicitConfFile) {
const std::string clPath = explicitConfFile;
// treat an empty path (`-conf=`) as missing command-line option,
// defaulting to an auto-located config file, analogous to DMD
if (!clPath.empty()) {
if (sys::fs::exists(clPath)) {
pathstr = clPath;
} else {
fprintf(stderr,
"Warning: configuration file '%s' not found, falling "
"back to default\n",
clPath.c_str());
}
// an empty path (`-conf=`) means no config file
if (clPath.empty())
return true;

if (sys::fs::exists(clPath)) {
pathstr = clPath;
} else {
fprintf(stderr,
"Warning: configuration file '%s' not found, falling "
"back to default\n",
clPath.c_str());
}
}

Expand Down
4 changes: 2 additions & 2 deletions driver/exe_path.cpp
Expand Up @@ -52,13 +52,13 @@ string exe_path::getLibDir() {
return r.str();
}

string exe_path::prependBinDir(const char *suffix) {
string exe_path::prependBinDir(const llvm::Twine &suffix) {
llvm::SmallString<128> r(getBinDir());
path::append(r, suffix);
return r.str();
}

string exe_path::prependLibDir(const char *suffix) {
string exe_path::prependLibDir(const llvm::Twine &suffix) {
llvm::SmallString<128> r(getLibDir());
path::append(r, suffix);
return r.str();
Expand Down
6 changes: 4 additions & 2 deletions driver/exe_path.h
Expand Up @@ -15,6 +15,8 @@
#ifndef LDC_DRIVER_EXE_PATH_H
#define LDC_DRIVER_EXE_PATH_H

#include "llvm/ADT/Twine.h"

#include <string>

namespace exe_path {
Expand All @@ -25,8 +27,8 @@ const std::string &getExePath(); // <baseDir>/bin/ldc2
std::string getBinDir(); // <baseDir>/bin
std::string getBaseDir(); // <baseDir>
std::string getLibDir(); // <baseDir>/lib
std::string prependBinDir(const char *suffix); // <baseDir>/bin/<suffix>
std::string prependLibDir(const char *suffix); // <baseDir>/lib/<suffix>
std::string prependBinDir(const llvm::Twine &suffix); // <baseDir>/bin/<suffix>
std::string prependLibDir(const llvm::Twine &suffix); // <baseDir>/lib/<suffix>
}

#endif // LDC_DRIVER_EXE_PATH_H
35 changes: 6 additions & 29 deletions driver/ldmd.cpp
Expand Up @@ -10,37 +10,12 @@
//
// Wrapper allowing use of LDC as drop-in replacement for DMD.
//
// The reason why full command line parsing is required instead of just
// rewriting the names of a few switches is an annoying impedance mismatch
// between the way how DMD handles arguments and the LLVM command line library:
// DMD allows all switches to be specified multiple times – in case of
// conflicts, the last one takes precedence. There is no easy way to replicate
// this behavior with LLVM, save parsing the switches and re-emitting a cleaned
// up string.
// Most command-line options are passed through to LDC; some with different
// names or semantics need to be translated.
//
// DMD also reads switches from the DFLAGS enviroment variable, if present. This
// is contrary to what C compilers do, where CFLAGS is usually handled by the
// build system. Thus, conflicts like mentioned above occur quite frequently in
// practice in makefiles written for DMD, as DFLAGS is also a natural name for
// handling flags there.
//
// In order to maintain backwards compatibility with earlier versions of LDMD,
// unknown switches are passed through verbatim to LDC. Finding a better
// solution for this is tricky, as some of the LLVM arguments can be
// intentionally specified multiple times to get a certain effect (e.g. pass,
// linker options).
//
// Just as with the old LDMD script, arguments can be passed through unmodified
// to LDC by using -Csomearg.
//
// If maintaining this wrapper is deemed too messy at some point, an alternative
// would be to either extend the LLVM command line library to support the DMD
// semantics (unlikely to happen), or to abandon it altogether (except for
// passing the LLVM-defined flags to the various passes).
//
// Note: This program inherited ugly C-style string handling and memory leaks
// from DMD, but this should not be a problem due to the short-livedness of
// the process.
// build system.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -75,9 +50,11 @@

namespace ls = llvm::sys;

// We reuse DMD's response file parsing routine for maximum compatibilty - it
// We reuse DMD's response file parsing routine for maximum compatibility - it
// handles quotes in a very peculiar way.
int response_expand(size_t *pargc, char ***pargv);

// in ddmd/root/man.d
void browse(const char *url);

/**
Expand Down
7 changes: 1 addition & 6 deletions driver/ldmd.d
@@ -1,4 +1,4 @@
//===-- driver/ldmd.d - General LLVM codegen helpers ----------*- D -*-===//
//===-- driver/ldmd.d ---------------------------------------------*- D -*-===//
//
// LDC – the LLVM D compiler
//
Expand All @@ -19,11 +19,6 @@ extern(C++) int cppmain(int argc, char **argv);
+/
int main()
{
// For now, even just the frontend does not work with GC enabled, so we need
// to disable it entirely.
import core.memory;
GC.disable();

import core.runtime;
auto args = Runtime.cArgs();
return cppmain(args.argc, cast(char**)args.argv);
Expand Down

0 comments on commit 66241ab

Please sign in to comment.