CMake: Fix LLVM_INTRINSIC_TD_PATH and LDC_INSTALL_PREFIX expansion (#3223)

In -std=gnu* mode, `linux` is a macro that expands to 1. If
LLVM_INTRINSIC_TD_PATH (bare string) contains `linux` (e.g.
x86_64-linux-gnu), LLVM_INTRINSIC_TD_PATH in gen_gccbuiltins.cpp will be
expanded and the whole string will get corrupted.

Fix it by switching from bare strings to C++ raw string literals
(preserving Windows backslashes).
This commit is contained in:
Fangrui Song 2019-11-11 11:54:56 -08:00 committed by Martin Kinkelin
parent 94743b90fc
commit 91aeb0e674
5 changed files with 19 additions and 20 deletions

View file

@ -55,19 +55,23 @@ DComputeCodeGenManager::createComputeTarget(const std::string &s) {
}
#endif
#define XSTR(x) #x
#define STR(x) XSTR((x))
#define STR(x) #x
#define XSTR(x) STR(x)
error(Loc(),
"unrecognised or invalid DCompute targets: the format is ocl-xy0 "
"for OpenCl x.y and cuda-xy0 for CUDA CC x.y."
#if LDC_LLVM_SUPPORTED_TARGET_SPIRV
" Valid versions for OpenCl are " STR(OCL_VALID_VER_INIT) "."
" Valid versions for OpenCl are " XSTR((OCL_VALID_VER_INIT)) "."
#endif
#if LDC_LLVM_SUPPORTED_TARGET_NVPTX
" Valid versions for CUDA are " STR(CUDA_VALID_VER_INIT)
" Valid versions for CUDA are " XSTR((CUDA_VALID_VER_INIT))
#endif
);
#undef XSTR
#undef STR
fatal();
return nullptr;
}