mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-14 15:16:07 +03:00
Merge branch 'master' into merge-2.079
Conflicts: appveyor.yml driver/main.cpp runtime/druntime runtime/phobos
This commit is contained in:
commit
025c69cc65
26 changed files with 189 additions and 69 deletions
|
@ -255,8 +255,8 @@ jobs:
|
||||||
- image: ubuntu:14.04
|
- image: ubuntu:14.04
|
||||||
environment:
|
environment:
|
||||||
- CI_OS: linux
|
- CI_OS: linux
|
||||||
- LLVM_VERSION: 5.0.1
|
- LLVM_VERSION: 6.0.0
|
||||||
- HOST_LDC_VERSION: 1.6.0
|
- HOST_LDC_VERSION: 1.8.0
|
||||||
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON"
|
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -DLDC_INSTALL_LTOPLUGIN=ON -DLDC_INSTALL_LLVM_RUNTIME_LIBS=ON"
|
||||||
- DUB_VERSION: v1.7.2
|
- DUB_VERSION: v1.7.2
|
||||||
build-osx:
|
build-osx:
|
||||||
|
@ -267,8 +267,8 @@ jobs:
|
||||||
- CI_OS: osx
|
- CI_OS: osx
|
||||||
- MACOSX_DEPLOYMENT_TARGET: 10.8
|
- MACOSX_DEPLOYMENT_TARGET: 10.8
|
||||||
- USE_LIBCPP: true
|
- USE_LIBCPP: true
|
||||||
- LLVM_VERSION: 5.0.1
|
- LLVM_VERSION: 6.0.0
|
||||||
- HOST_LDC_VERSION: 1.6.0
|
- HOST_LDC_VERSION: 1.8.0
|
||||||
- BOOTSTRAP_CMAKE_FLAGS: "-DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_EXE_LINKER_FLAGS=-lc++"
|
- BOOTSTRAP_CMAKE_FLAGS: "-DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_EXE_LINKER_FLAGS=-lc++"
|
||||||
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_EXE_LINKER_FLAGS=-lc++"
|
- EXTRA_CMAKE_FLAGS: "-DMULTILIB=ON -DCMAKE_CXX_FLAGS='-stdlib=libc++' -DCMAKE_EXE_LINKER_FLAGS=-lc++"
|
||||||
- DUB_VERSION: v1.7.2
|
- DUB_VERSION: v1.7.2
|
||||||
|
|
|
@ -6,13 +6,16 @@ matrix:
|
||||||
include:
|
include:
|
||||||
- os: linux
|
- os: linux
|
||||||
d: ldc
|
d: ldc
|
||||||
|
env: LLVM_VERSION=6.0.0
|
||||||
|
- os: linux
|
||||||
|
d: ldc-beta
|
||||||
env: LLVM_VERSION=5.0.1 OPTS="-DLIB_SUFFIX=64"
|
env: LLVM_VERSION=5.0.1 OPTS="-DLIB_SUFFIX=64"
|
||||||
- os: linux
|
- os: linux
|
||||||
d: ldc
|
d: ldc
|
||||||
env: LLVM_VERSION=4.0.1 OPTS="-DLIB_SUFFIX=64"
|
env: LLVM_VERSION=4.0.1 OPTS="-DBUILD_SHARED_LIBS=ON"
|
||||||
- os: linux
|
- os: linux
|
||||||
d: ldc-beta
|
d: ldc-beta
|
||||||
env: LLVM_VERSION=3.9.1 OPTS="-DBUILD_SHARED_LIBS=ON"
|
env: LLVM_VERSION=3.9.1 OPTS="-DBUILD_SHARED_LIBS=ON -DLIB_SUFFIX=64"
|
||||||
- os: linux
|
- os: linux
|
||||||
d: ldc-0.17.5
|
d: ldc-0.17.5
|
||||||
env: LLVM_VERSION=3.8.1 OPTS="-DBUILD_SHARED_LIBS=OFF -DLIB_SUFFIX=64"
|
env: LLVM_VERSION=3.8.1 OPTS="-DBUILD_SHARED_LIBS=OFF -DLIB_SUFFIX=64"
|
||||||
|
@ -31,6 +34,7 @@ matrix:
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- llvm-spirv-6.0.0
|
- llvm-spirv-6.0.0
|
||||||
|
- llvm-6.0.0
|
||||||
- llvm-5.0.1
|
- llvm-5.0.1
|
||||||
- llvm-4.0.1
|
- llvm-4.0.1
|
||||||
- llvm-4.0.0
|
- llvm-4.0.0
|
||||||
|
|
|
@ -24,11 +24,16 @@ endif()
|
||||||
#
|
#
|
||||||
|
|
||||||
find_package(LLVM 3.7 REQUIRED
|
find_package(LLVM 3.7 REQUIRED
|
||||||
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb globalisel instcombine ipa ipo instrumentation irreader libdriver linker lto mc mcdisassembler mcparser objcarcopts object option profiledata scalaropts selectiondag support tablegen target transformutils vectorize ${EXTRA_LLVM_MODULES})
|
all-targets analysis asmparser asmprinter bitreader bitwriter codegen core
|
||||||
|
debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb globalisel
|
||||||
|
instcombine ipa ipo instrumentation irreader libdriver linker lto mc
|
||||||
|
mcdisassembler mcparser objcarcopts object option profiledata scalaropts
|
||||||
|
selectiondag support tablegen target transformutils vectorize
|
||||||
|
windowsmanifest ${EXTRA_LLVM_MODULES})
|
||||||
math(EXPR LDC_LLVM_VER ${LLVM_VERSION_MAJOR}*100+${LLVM_VERSION_MINOR})
|
math(EXPR LDC_LLVM_VER ${LLVM_VERSION_MAJOR}*100+${LLVM_VERSION_MINOR})
|
||||||
# Remove LLVMTableGen library from list of libraries
|
# Remove LLVMTableGen library from list of libraries
|
||||||
string(REGEX MATCH "^-.*LLVMTableGen[^;]*;|;-.*LLVMTableGen[^;]*" LLVM_TABLEGEN_LIBRARY "${LLVM_LIBRARIES}")
|
string(REGEX MATCH "[^;]*LLVMTableGen[^;]*" LLVM_TABLEGEN_LIBRARY "${LLVM_LIBRARIES}")
|
||||||
string(REGEX REPLACE "^-.*LLVMTableGen[^;]*;|;-.*LLVMTableGen[^;]*" "" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
|
string(REGEX REPLACE "[^;]*LLVMTableGen[^;]*;?" "" LLVM_LIBRARIES "${LLVM_LIBRARIES}")
|
||||||
|
|
||||||
# Information about which targets LLVM was built to target
|
# Information about which targets LLVM was built to target
|
||||||
foreach(LLVM_SUPPORTED_TARGET ${LLVM_TARGETS_TO_BUILD})
|
foreach(LLVM_SUPPORTED_TARGET ${LLVM_TARGETS_TO_BUILD})
|
||||||
|
@ -223,6 +228,11 @@ endif()
|
||||||
append("${SANITIZE_CXXFLAGS}" LDC_CXXFLAGS)
|
append("${SANITIZE_CXXFLAGS}" LDC_CXXFLAGS)
|
||||||
# LLVM_CXXFLAGS may contain -Werror which causes compile errors with dmd source
|
# LLVM_CXXFLAGS may contain -Werror which causes compile errors with dmd source
|
||||||
string(REPLACE "-Werror " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
string(REPLACE "-Werror " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
||||||
|
# LLVM_CXXFLAGS may contain -Werror=unguarded-availability-new which requires
|
||||||
|
# more recent gcc versions (not supported by 4.9)
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
string(REPLACE "-Werror=unguarded-availability-new " "" LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
|
||||||
|
endif()
|
||||||
if (UNIX AND NOT "${LLVM_LDFLAGS}" STREQUAL "")
|
if (UNIX AND NOT "${LLVM_LDFLAGS}" STREQUAL "")
|
||||||
# LLVM_LDFLAGS may contain -l-lld which is a wrong library reference (AIX)
|
# LLVM_LDFLAGS may contain -l-lld which is a wrong library reference (AIX)
|
||||||
string(REPLACE "-l-lld " "-lld " LLVM_LDFLAGS ${LLVM_LDFLAGS})
|
string(REPLACE "-l-lld " "-lld " LLVM_LDFLAGS ${LLVM_LDFLAGS})
|
||||||
|
@ -433,7 +443,11 @@ if(NOT DEFINED LDC_WITH_LLD)
|
||||||
set(CMAKE_REQUIRED_FLAGS -std=c++11)
|
set(CMAKE_REQUIRED_FLAGS -std=c++11)
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIRS})
|
set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIRS})
|
||||||
CHECK_INCLUDE_FILE_CXX(lld/Driver/Driver.h LDC_WITH_LLD)
|
if(NOT (LDC_LLVM_VER LESS 600))
|
||||||
|
CHECK_INCLUDE_FILE_CXX(lld/Common/Driver.h LDC_WITH_LLD)
|
||||||
|
else()
|
||||||
|
CHECK_INCLUDE_FILE_CXX(lld/Driver/Driver.h LDC_WITH_LLD)
|
||||||
|
endif()
|
||||||
unset(CMAKE_REQUIRED_FLAGS)
|
unset(CMAKE_REQUIRED_FLAGS)
|
||||||
unset(CMAKE_REQUIRED_INCLUDES)
|
unset(CMAKE_REQUIRED_INCLUDES)
|
||||||
else()
|
else()
|
||||||
|
@ -549,10 +563,20 @@ add_custom_target(${LDMD_EXE} ALL DEPENDS ${LDMD_EXE_FULL})
|
||||||
# LLVM flags into account.
|
# LLVM flags into account.
|
||||||
set(LDC_LINKERFLAG_LIST "${SANITIZE_LDFLAGS};${LLVM_LIBRARIES};${LLVM_LDFLAGS}")
|
set(LDC_LINKERFLAG_LIST "${SANITIZE_LDFLAGS};${LLVM_LIBRARIES};${LLVM_LDFLAGS}")
|
||||||
if(LDC_WITH_LLD)
|
if(LDC_WITH_LLD)
|
||||||
if(MSVC)
|
if(NOT (LDC_LLVM_VER LESS 600))
|
||||||
list(APPEND LDC_LINKERFLAG_LIST lldCOFF.lib lldCore.lib lldDriver.lib)
|
if(MSVC)
|
||||||
|
list(APPEND LDC_LINKERFLAG_LIST lldCOFF.lib lldCommon.lib lldCore.lib lldDriver.lib)
|
||||||
|
elseif(APPLE)
|
||||||
|
set(LDC_LINKERFLAG_LIST "-llldCOFF;-llldCommon;-llldCore;-llldDriver;${LDC_LINKERFLAG_LIST};-lxml2")
|
||||||
|
else()
|
||||||
|
set(LDC_LINKERFLAG_LIST "-llldCOFF;-llldCommon;-llldCore;-llldDriver;${LDC_LINKERFLAG_LIST}")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
set(LDC_LINKERFLAG_LIST "-llldCOFF;-llldCore;-llldDriver;${LDC_LINKERFLAG_LIST}")
|
if(MSVC)
|
||||||
|
list(APPEND LDC_LINKERFLAG_LIST lldCOFF.lib lldCore.lib lldDriver.lib)
|
||||||
|
else()
|
||||||
|
set(LDC_LINKERFLAG_LIST "-llldCOFF;-llldCore;-llldDriver;${LDC_LINKERFLAG_LIST}")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
19
README.md
19
README.md
|
@ -45,16 +45,17 @@ can also be used to install LDC:
|
||||||
|
|
||||||
In addition, LDC is available from various package managers:
|
In addition, LDC is available from various package managers:
|
||||||
|
|
||||||
| | Command |
|
| | Command |
|
||||||
| ------------ | ------------------------------------------- |
|
| ------------ | -------------------------------------------- |
|
||||||
| Arch Linux | `pacman -S ldc` |
|
| Arch Linux | `pacman -S ldc` |
|
||||||
| Debian | `apt install ldc` |
|
| Debian | `apt install ldc` |
|
||||||
| Fedora | `dnf install ldc` |
|
| Fedora | `dnf install ldc` |
|
||||||
| Gentoo | `layman -a ldc` |
|
| Gentoo | `layman -a ldc` |
|
||||||
| Homebrew | `brew install ldc` |
|
| Homebrew | `brew install ldc` |
|
||||||
| Ubuntu | `apt install ldc` |
|
| Ubuntu | `apt install ldc` |
|
||||||
| Snap | `snap install --classic --channel=edge ldc2` |
|
| Snap | `snap install --classic --channel=edge ldc2` |
|
||||||
| Nix/NixOS | `nix-env -i ldc` |
|
| Nix/NixOS | `nix-env -i ldc` |
|
||||||
|
| Chocolatey | `choco ldc` |
|
||||||
|
|
||||||
Note that these packages **might be outdated** as they are not
|
Note that these packages **might be outdated** as they are not
|
||||||
currently integrated into the project release process.
|
currently integrated into the project release process.
|
||||||
|
|
21
appveyor.yml
21
appveyor.yml
|
@ -12,13 +12,13 @@ environment:
|
||||||
matrix:
|
matrix:
|
||||||
- APPVEYOR_JOB_ARCH: x64
|
- APPVEYOR_JOB_ARCH: x64
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
LLVM_VERSION: 5.0.1
|
LLVM_VERSION: 6.0.0
|
||||||
HOST_LDC_VERSION: 1.8.0-beta1
|
HOST_LDC_VERSION: 1.8.0
|
||||||
DUB_VERSION: v1.7.2
|
DUB_VERSION: v1.7.2
|
||||||
- APPVEYOR_JOB_ARCH: x86
|
- APPVEYOR_JOB_ARCH: x86
|
||||||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||||
LLVM_VERSION: 5.0.1
|
LLVM_VERSION: 5.0.1
|
||||||
HOST_LDC_VERSION: 1.8.0-beta1
|
HOST_LDC_VERSION: 1.8.0
|
||||||
DUB_VERSION: v1.7.2
|
DUB_VERSION: v1.7.2
|
||||||
|
|
||||||
# scripts that are called at very beginning, before repo cloning
|
# scripts that are called at very beginning, before repo cloning
|
||||||
|
@ -64,15 +64,9 @@ install:
|
||||||
- ps: |
|
- ps: |
|
||||||
If (Test-Path Env:HOST_LDC_VERSION) {
|
If (Test-Path Env:HOST_LDC_VERSION) {
|
||||||
$ldcVersion = $Env:HOST_LDC_VERSION
|
$ldcVersion = $Env:HOST_LDC_VERSION
|
||||||
If ($Env:APPVEYOR_JOB_ARCH -eq 'x64') {
|
appveyor DownloadFile "http://github.com/ldc-developers/ldc/releases/download/v$ldcVersion/ldc2-$ldcVersion-windows-$Env:APPVEYOR_JOB_ARCH.7z" -FileName ldc2.7z
|
||||||
appveyor DownloadFile "http://github.com/ldc-developers/ldc/releases/download/v$ldcVersion/ldc2-$ldcVersion-windows-multilib.7z" -FileName ldc2.7z
|
7z x ldc2.7z > $null
|
||||||
7z x ldc2.7z > $null
|
Set-Item -path env:DMD -value "c:\projects\ldc2-$ldcVersion-windows-$Env:APPVEYOR_JOB_ARCH\bin\ldmd2.exe"
|
||||||
Set-Item -path env:DMD -value "c:\projects\ldc2-$ldcVersion-windows-multilib\bin\ldmd2.exe"
|
|
||||||
} Else {
|
|
||||||
appveyor DownloadFile "http://github.com/ldc-developers/ldc/releases/download/v$ldcVersion/ldc2-$ldcVersion-windows-x86.7z" -FileName ldc2.7z
|
|
||||||
7z x ldc2.7z > $null
|
|
||||||
Set-Item -path env:DMD -value "c:\projects\ldc2-$ldcVersion-windows-x86\bin\ldmd2.exe"
|
|
||||||
}
|
|
||||||
} Else {
|
} Else {
|
||||||
$dmdVersion = $Env:HOST_DMD_VERSION
|
$dmdVersion = $Env:HOST_DMD_VERSION
|
||||||
appveyor DownloadFile "http://downloads.dlang.org/releases/2.x/$dmdVersion/dmd.$dmdVersion.windows.7z" -FileName dmd.7z
|
appveyor DownloadFile "http://downloads.dlang.org/releases/2.x/$dmdVersion/dmd.$dmdVersion.windows.7z" -FileName dmd.7z
|
||||||
|
@ -137,6 +131,9 @@ test_script:
|
||||||
# Build and run LDC D unittests
|
# Build and run LDC D unittests
|
||||||
- ctest --output-on-failure -R "ldc2-unittest"
|
- ctest --output-on-failure -R "ldc2-unittest"
|
||||||
# Run LIT testsuite
|
# Run LIT testsuite
|
||||||
|
# Exclude linking/link_internally.d with LLD < 6 due to a magic symbol
|
||||||
|
# required since VS 2017 v15.5 (see https://reviews.llvm.org/D41089).
|
||||||
|
- ps: If ($($Env:LLVM_VERSION[0]) -lt '6') { del ..\ldc\tests\linking\link_internally.d }
|
||||||
- ctest -V -R "lit-tests"
|
- ctest -V -R "lit-tests"
|
||||||
# Run DMD testsuite
|
# Run DMD testsuite
|
||||||
- if "%APPVEYOR_JOB_ARCH%"=="x64" ( set OS=Win_64) else ( set OS=Win_32)
|
- if "%APPVEYOR_JOB_ARCH%"=="x64" ( set OS=Win_64) else ( set OS=Win_32)
|
||||||
|
|
|
@ -122,6 +122,10 @@ else()
|
||||||
# Versions below 4.0 do not support component debuginfomsf
|
# Versions below 4.0 do not support component debuginfomsf
|
||||||
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfomsf" index)
|
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "debuginfomsf" index)
|
||||||
endif()
|
endif()
|
||||||
|
if(${LLVM_VERSION_STRING} MATCHES "^[3-5]\\..*")
|
||||||
|
# Versions below 6.0 do not support component windowsmanifest
|
||||||
|
list(REMOVE_ITEM LLVM_FIND_COMPONENTS "windowsmanifest" index)
|
||||||
|
endif()
|
||||||
|
|
||||||
llvm_set(LDFLAGS ldflags)
|
llvm_set(LDFLAGS ldflags)
|
||||||
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
|
# In LLVM 3.5+, the system library dependencies (e.g. "-lz") are accessed
|
||||||
|
|
|
@ -18,8 +18,12 @@
|
||||||
#include "llvm/Support/FileSystem.h"
|
#include "llvm/Support/FileSystem.h"
|
||||||
|
|
||||||
#if LDC_WITH_LLD
|
#if LDC_WITH_LLD
|
||||||
|
#if LDC_LLVM_VER >= 600
|
||||||
|
#include "lld/Common/Driver.h"
|
||||||
|
#else
|
||||||
#include "lld/Driver/Driver.h"
|
#include "lld/Driver/Driver.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -195,7 +199,11 @@ int linkObjToBinaryMSVC(llvm::StringRef outputPath, bool useInternalLinker,
|
||||||
const auto fullArgs =
|
const auto fullArgs =
|
||||||
getFullArgs("lld-link.exe", args, global.params.verbose);
|
getFullArgs("lld-link.exe", args, global.params.verbose);
|
||||||
|
|
||||||
|
#if LDC_LLVM_VER >= 600
|
||||||
|
const bool success = lld::coff::link(fullArgs, /*CanExitEarly=*/false);
|
||||||
|
#else
|
||||||
const bool success = lld::coff::link(fullArgs);
|
const bool success = lld::coff::link(fullArgs);
|
||||||
|
#endif
|
||||||
if (!success)
|
if (!success)
|
||||||
error(Loc(), "linking with LLD failed");
|
error(Loc(), "linking with LLD failed");
|
||||||
|
|
||||||
|
|
|
@ -526,17 +526,15 @@ void parseCommandLine(int argc, char **argv, Strings &sourceFiles,
|
||||||
"overrides the existing list instead of appending to "
|
"overrides the existing list instead of appending to "
|
||||||
"it. Please use the latter instead.");
|
"it. Please use the latter instead.");
|
||||||
} else if (!global.params.betterC) {
|
} else if (!global.params.betterC) {
|
||||||
if (linkDefaultLibShared && staticFlag == cl::BOU_TRUE) {
|
|
||||||
error(Loc(), "Can't use -link-defaultlib-shared and -static together");
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool addDebugSuffix =
|
const bool addDebugSuffix =
|
||||||
(linkDefaultLibDebug && debugLib.getNumOccurrences() == 0);
|
(linkDefaultLibDebug && debugLib.getNumOccurrences() == 0);
|
||||||
// Default to shared default libs for DLLs compiled without -static.
|
|
||||||
|
// -static enforces static default libs.
|
||||||
|
// Default to shared default libs for DLLs.
|
||||||
const bool addSharedSuffix =
|
const bool addSharedSuffix =
|
||||||
linkDefaultLibShared ||
|
staticFlag != cl::BOU_TRUE &&
|
||||||
(linkDefaultLibShared.getNumOccurrences() == 0 && global.params.dll &&
|
(linkDefaultLibShared ||
|
||||||
staticFlag != cl::BOU_TRUE);
|
(linkDefaultLibShared.getNumOccurrences() == 0 && global.params.dll));
|
||||||
|
|
||||||
// Parse comma-separated default library list.
|
// Parse comma-separated default library list.
|
||||||
std::stringstream libNames(
|
std::stringstream libNames(
|
||||||
|
@ -1030,7 +1028,7 @@ int cppmain(int argc, char **argv) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl::PrintHelpMessage();
|
cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,6 +458,12 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
|
||||||
if (targetOptions.MCOptions.ABIName.empty())
|
if (targetOptions.MCOptions.ABIName.empty())
|
||||||
targetOptions.MCOptions.ABIName = getABI(triple);
|
targetOptions.MCOptions.ABIName = getABI(triple);
|
||||||
|
|
||||||
|
#if LDC_LLVM_VER >= 600
|
||||||
|
// druntime isn't ready for Dwarf v4+ debuginfos (e.g., in rt.backtrace.dwarf).
|
||||||
|
if (targetOptions.MCOptions.DwarfVersion == 0)
|
||||||
|
targetOptions.MCOptions.DwarfVersion = 3;
|
||||||
|
#endif
|
||||||
|
|
||||||
auto ldcFloatABI = floatABI;
|
auto ldcFloatABI = floatABI;
|
||||||
if (ldcFloatABI == FloatABI::Default) {
|
if (ldcFloatABI == FloatABI::Default) {
|
||||||
switch (triple.getArch()) {
|
switch (triple.getArch()) {
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef enum {
|
||||||
Reg_EDI,
|
Reg_EDI,
|
||||||
Reg_EBP,
|
Reg_EBP,
|
||||||
Reg_ESP,
|
Reg_ESP,
|
||||||
|
Reg_EIP,
|
||||||
Reg_ST,
|
Reg_ST,
|
||||||
Reg_ST1,
|
Reg_ST1,
|
||||||
Reg_ST2,
|
Reg_ST2,
|
||||||
|
@ -160,9 +161,9 @@ typedef enum {
|
||||||
Reg_TR7
|
Reg_TR7
|
||||||
} Reg;
|
} Reg;
|
||||||
|
|
||||||
static const int N_Regs = /*gp*/ 8 + /*fp*/ 8 + /*mmx*/ 8 + /*sse*/ 8 +
|
static const int N_Regs = /*gp*/ 8 + /*EIP*/ 1 + /*fp*/ 8 + /*mmx*/ 8 + /*sse*/ 8 +
|
||||||
/*seg*/ 6 + /*16bit*/ 8 + /*8bit*/ 8 + /*sys*/ 4 + 6 +
|
/*seg*/ 6 + /*16bit*/ 8 + /*8bit*/ 8 + /*sys*/ 4 + 6 +
|
||||||
5 + /*flags*/ +1
|
5 + /*flags*/ 1
|
||||||
#ifdef ASM_X86_64
|
#ifdef ASM_X86_64
|
||||||
+ 8 /*RAX, etc*/
|
+ 8 /*RAX, etc*/
|
||||||
+ 8 /*R8-15*/
|
+ 8 /*R8-15*/
|
||||||
|
@ -193,6 +194,7 @@ static struct {
|
||||||
{"EDI", NULL_TREE, nullptr, 4, Reg_EDI},
|
{"EDI", NULL_TREE, nullptr, 4, Reg_EDI},
|
||||||
{"EBP", NULL_TREE, nullptr, 4, Reg_EBP},
|
{"EBP", NULL_TREE, nullptr, 4, Reg_EBP},
|
||||||
{"ESP", NULL_TREE, nullptr, 4, Reg_ESP},
|
{"ESP", NULL_TREE, nullptr, 4, Reg_ESP},
|
||||||
|
{"EIP", NULL_TREE, nullptr, 4, Reg_EIP},
|
||||||
{"ST", NULL_TREE, nullptr, 10, Reg_ST},
|
{"ST", NULL_TREE, nullptr, 10, Reg_ST},
|
||||||
{"ST(1)", NULL_TREE, nullptr, 10, Reg_ST1},
|
{"ST(1)", NULL_TREE, nullptr, 10, Reg_ST1},
|
||||||
{"ST(2)", NULL_TREE, nullptr, 10, Reg_ST2},
|
{"ST(2)", NULL_TREE, nullptr, 10, Reg_ST2},
|
||||||
|
|
|
@ -108,12 +108,14 @@ Statement *asmSemantic(AsmStatement *s, Scope *sc) {
|
||||||
llvm::Triple const &t = *global.params.targetTriple;
|
llvm::Triple const &t = *global.params.targetTriple;
|
||||||
if (!(t.getArch() == llvm::Triple::x86 ||
|
if (!(t.getArch() == llvm::Triple::x86 ||
|
||||||
t.getArch() == llvm::Triple::x86_64)) {
|
t.getArch() == llvm::Triple::x86_64)) {
|
||||||
s->error("inline asm is not supported for the \"%s\" architecture",
|
s->error("the `asm` statement is not supported for the \"%s\" "
|
||||||
|
"architecture, use `ldc.llvmasm.__asm` instead",
|
||||||
t.getArchName().str().c_str());
|
t.getArchName().str().c_str());
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
if (!global.params.useInlineAsm) {
|
if (!global.params.useInlineAsm) {
|
||||||
s->error("inline asm is not allowed when the -noasm switch is used");
|
s->error(
|
||||||
|
"the `asm` statement is not allowed when the -noasm switch is used");
|
||||||
err = true;
|
err = true;
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -442,7 +442,8 @@ void IrAggr::defineInterfaceVtbl(BaseClass *b, bool new_instance,
|
||||||
// call the real vtbl function.
|
// call the real vtbl function.
|
||||||
llvm::CallInst *call = gIR->ir->CreateCall(callee, args);
|
llvm::CallInst *call = gIR->ir->CreateCall(callee, args);
|
||||||
call->setCallingConv(irFunc->getCallingConv());
|
call->setCallingConv(irFunc->getCallingConv());
|
||||||
call->setTailCallKind(llvm::CallInst::TCK_Tail);
|
call->setTailCallKind(thunk->isVarArg() ? llvm::CallInst::TCK_MustTail
|
||||||
|
: llvm::CallInst::TCK_Tail);
|
||||||
|
|
||||||
// return from the thunk
|
// return from the thunk
|
||||||
if (thunk->getReturnType() == LLType::getVoidTy(gIR->context())) {
|
if (thunk->getReturnType() == LLType::getVoidTy(gIR->context())) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6ffb38debae2773178c2c309c30de3d49bd378fe
|
Subproject commit eded8ada8598cc78a46c53c93d1264efe9a77451
|
|
@ -1 +1 @@
|
||||||
Subproject commit 64d273b7c00f187266425415cd58726f06d2edc8
|
Subproject commit 854fb3aa12c75c0e61b626ba59ad199706c1fb6b
|
|
@ -1,9 +1,10 @@
|
||||||
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
|
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
|
||||||
// RUN: %ldc -c -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
|
// RUN: %ldc -c -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
|
||||||
|
|
||||||
int foo() {
|
// Try to keep these very simple checks independent of architecture.
|
||||||
|
|
||||||
|
// ASM: foofoofoofoo:
|
||||||
|
extern(C) int foofoofoofoo() {
|
||||||
|
// LLVM: ret i32 42
|
||||||
return 42;
|
return 42;
|
||||||
// Try to keep these very simple checks independent of architecture:
|
|
||||||
// LLVM: ret i32 42
|
|
||||||
// ASM: {{(\$|#|.long )}}42
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import ldc.attributes;
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// CHECK-LABEL: define i32 @_Dmain
|
// CHECK-LABEL: define{{.*}} i32 @_Dmain
|
||||||
void main() {
|
void main() {
|
||||||
sectionedfoo();
|
sectionedfoo();
|
||||||
}
|
}
|
||||||
|
|
17
tests/codegen/dmd_inline_asm_ip.d
Normal file
17
tests/codegen/dmd_inline_asm_ip.d
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// REQUIRES: target_X86
|
||||||
|
|
||||||
|
// RUN: %ldc -output-s -x86-asm-syntax=intel -mtriple=x86_64-linux-gnu -of=%t.s %s
|
||||||
|
// RUN: FileCheck %s < %t.s
|
||||||
|
|
||||||
|
// CHECK: _D17dmd_inline_asm_ip3fooFZm
|
||||||
|
ulong foo()
|
||||||
|
{
|
||||||
|
asm
|
||||||
|
{
|
||||||
|
// CHECK: mov eax, dword ptr [eip]
|
||||||
|
mov EAX, [EIP];
|
||||||
|
// CHECK-NEXT: mov rax, qword ptr [rip]
|
||||||
|
mov RAX, [RIP];
|
||||||
|
ret;
|
||||||
|
}
|
||||||
|
}
|
22
tests/codegen/variadic_thunk_gh2613.d
Normal file
22
tests/codegen/variadic_thunk_gh2613.d
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// RUN: %ldc -run %s
|
||||||
|
|
||||||
|
interface Stream
|
||||||
|
{
|
||||||
|
void write(...);
|
||||||
|
}
|
||||||
|
|
||||||
|
class OutputStream : Stream
|
||||||
|
{
|
||||||
|
void write(...)
|
||||||
|
{
|
||||||
|
import core.vararg;
|
||||||
|
auto arg = va_arg!string(_argptr);
|
||||||
|
assert(arg == "Hello world");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
Stream stream = new OutputStream;
|
||||||
|
stream.write("Hello world");
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
// REQUIRES: atleast_llvm500
|
// REQUIRES: atleast_llvm500
|
||||||
|
// REQUIRES: atmost_llvm501
|
||||||
// REQUIRES: Windows
|
// REQUIRES: Windows
|
||||||
// REQUIRES: cdb
|
// REQUIRES: cdb
|
||||||
// RUN: %ldc -g -of=%t.exe %s
|
// RUN: %ldc -g -of=%t.exe %s
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
void encloser(int arg0, ref int arg1)
|
void encloser(int arg0, ref int arg1)
|
||||||
{
|
{
|
||||||
int enc_n = 123;
|
int enc_n = 123;
|
||||||
// CDB: bp `nested_cdb.d:16`
|
// CDB: bp `nested_cdb.d:17`
|
||||||
// CDB: g
|
// CDB: g
|
||||||
// CDB: dv /t
|
// CDB: dv /t
|
||||||
// CHECK: int arg0 = 0n1
|
// CHECK: int arg0 = 0n1
|
||||||
|
@ -27,7 +28,7 @@ void encloser(int arg0, ref int arg1)
|
||||||
void nested(int nes_i)
|
void nested(int nes_i)
|
||||||
{
|
{
|
||||||
int blub = arg0 + arg1 + enc_n;
|
int blub = arg0 + arg1 + enc_n;
|
||||||
// CDB: bp `nested_cdb.d:30`
|
// CDB: bp `nested_cdb.d:31`
|
||||||
// CDB: g
|
// CDB: g
|
||||||
// CDB: dv /t
|
// CDB: dv /t
|
||||||
// CHECK: int arg0 = 0n1
|
// CHECK: int arg0 = 0n1
|
||||||
|
@ -36,7 +37,7 @@ void encloser(int arg0, ref int arg1)
|
||||||
// CDB: ?? *arg1
|
// CDB: ?? *arg1
|
||||||
// CHECK: int 0n2
|
// CHECK: int 0n2
|
||||||
arg0 = arg1 = enc_n = nes_i;
|
arg0 = arg1 = enc_n = nes_i;
|
||||||
// CDB: bp `nested_cdb.d:39`
|
// CDB: bp `nested_cdb.d:40`
|
||||||
// CDB: g
|
// CDB: g
|
||||||
// CDB: dv /t
|
// CDB: dv /t
|
||||||
// CHECK: int arg0 = 0n456
|
// CHECK: int arg0 = 0n456
|
||||||
|
@ -47,7 +48,7 @@ void encloser(int arg0, ref int arg1)
|
||||||
}
|
}
|
||||||
|
|
||||||
nested(456);
|
nested(456);
|
||||||
// CDB: bp `nested_cdb.d:50`
|
// CDB: bp `nested_cdb.d:51`
|
||||||
// CDB: g
|
// CDB: g
|
||||||
// CDB: dv /t
|
// CDB: dv /t
|
||||||
// the following values are garbage on Win32...
|
// the following values are garbage on Win32...
|
||||||
|
|
9
tests/linking/fullystatic.d
Normal file
9
tests/linking/fullystatic.d
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
/* Make sure -static overrides -link-defaultlib-shared.
|
||||||
|
* We only care about the default libs in the linker command line;
|
||||||
|
* make sure linking fails in all cases (no main()) as linking would
|
||||||
|
* fail if there are no static default libs (BUILD_SHARED_LIBS=ON).
|
||||||
|
*/
|
||||||
|
|
||||||
|
// RUN: not %ldc -v -static -link-defaultlib-shared %s | FileCheck %s
|
||||||
|
// CHECK-NOT: druntime-ldc-shared
|
||||||
|
// CHECK-NOT: phobos2-ldc-shared
|
9
tests/linking/link_internally.d
Normal file
9
tests/linking/link_internally.d
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
// REQUIRES: Windows
|
||||||
|
|
||||||
|
// RUN: %ldc -link-internally -run %s
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
import std.stdio;
|
||||||
|
writeln("Hello world");
|
||||||
|
}
|
|
@ -12,12 +12,12 @@
|
||||||
bool FuzzMe(const ubyte* data, size_t dataSize)
|
bool FuzzMe(const ubyte* data, size_t dataSize)
|
||||||
{
|
{
|
||||||
// PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard
|
// PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard
|
||||||
// PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_cmp
|
// PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp
|
||||||
// PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard
|
// PCGUARD: call {{.*}}_sanitizer_cov_trace_pc_guard
|
||||||
// PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_cmp
|
// PCGUARD-NOT: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp
|
||||||
|
|
||||||
// PCCMP: call {{.*}}_sanitizer_cov_trace_pc_guard
|
// PCCMP: call {{.*}}_sanitizer_cov_trace_pc_guard
|
||||||
// PCCMP: call {{.*}}_sanitizer_cov_trace_cmp
|
// PCCMP: call {{.*}}_sanitizer_cov_trace_{{(const_)?}}cmp
|
||||||
|
|
||||||
// PCFUNC: call {{.*}}_sanitizer_cov_trace_pc_guard
|
// PCFUNC: call {{.*}}_sanitizer_cov_trace_pc_guard
|
||||||
// PCFUNC-NOT: call {{.*}}_sanitizer_cov_trace_pc_guard
|
// PCFUNC-NOT: call {{.*}}_sanitizer_cov_trace_pc_guard
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
// Tests diagnostics of using data definition directives in inline asm.
|
// Tests diagnostics of using data definition directives in inline asm.
|
||||||
// Note: this test should be removed once we _do_ support them.
|
// Note: this test should be removed once we _do_ support them.
|
||||||
|
|
||||||
// RUN: not %ldc -c %s 2>&1 | FileCheck %s
|
// REQUIRES: target_X86
|
||||||
|
|
||||||
|
// RUN: not %ldc -mtriple=x86_64-linux-gnu -c %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
void foo()
|
void foo()
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,9 +81,6 @@ void func()
|
||||||
//CHECK-NOT: Error:
|
//CHECK-NOT: Error:
|
||||||
scope(exit)
|
scope(exit)
|
||||||
func2();
|
func2();
|
||||||
|
|
||||||
//CHECK: dcompute.d([[@LINE+1]]): Error: asm not allowed in `@compute` code
|
|
||||||
asm {ret;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void func1() {}
|
void func1() {}
|
||||||
|
|
15
tests/semantic/dcompute_asm.d
Normal file
15
tests/semantic/dcompute_asm.d
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Test that the "asm" statement is not allowed for DCompute code.
|
||||||
|
|
||||||
|
// "asm" is only allowed for X86, so we must explicitly target X86 in this test.
|
||||||
|
// REQUIRES: target_X86
|
||||||
|
|
||||||
|
// RUN: not %ldc -mtriple=x86_64-linux-gnu -o- %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
@compute(CompileFor.deviceOnly) module tests.semaintic.dcompute;
|
||||||
|
import ldc.dcompute;
|
||||||
|
|
||||||
|
void func()
|
||||||
|
{
|
||||||
|
//CHECK: dcompute_asm.d([[@LINE+1]]): Error: asm not allowed in `@compute` code
|
||||||
|
asm {ret;}
|
||||||
|
}
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
// REQUIRES: target_X86
|
// REQUIRES: target_X86
|
||||||
|
|
||||||
// RUN: %ldc -mcpu=haswell -d-version=CPU_HASWELL -c %s
|
// RUN: %ldc -mtriple=x86_64-apple-darwin -mcpu=haswell -d-version=CPU_HASWELL -c %s
|
||||||
// RUN: %ldc -mcpu=pentium -mattr=+fma -d-version=ATTR_FMA -c %s
|
// RUN: %ldc -mtriple=x86_64-apple-darwin -mcpu=pentium -mattr=+fma -d-version=ATTR_FMA -c %s
|
||||||
// RUN: %ldc -mcpu=pentium -mattr=+fma,-sse -d-version=ATTR_FMA_MINUS_SSE -c %s
|
// RUN: %ldc -mtriple=x86_64-apple-darwin -mcpu=pentium -mattr=+fma,-sse -d-version=ATTR_FMA_MINUS_SSE -c %s
|
||||||
|
|
||||||
// Important: LLVM's default CPU selection already enables some features (like sse3)
|
// Important: LLVM's default CPU selection already enables some features (like sse3)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue