Skip to content

[SYCL] Use same source for libsycl-crt #3019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 21, 2021
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: 2 additions & 4 deletions libdevice/cmake/modules/SYCLLibdevice.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ set(obj_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
if (WIN32)
set(lib-suffix obj)
set(spv_binary_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
set(lib_crt_source msvc_wrapper.cpp)
else()
set(lib-suffix o)
set(spv_binary_dir "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
set(lib_crt_source glibc_wrapper.cpp)
endif()
set(clang $<TARGET_FILE:clang>)

Expand All @@ -33,9 +31,9 @@ set(devicelib-obj-file ${obj_binary_dir}/libsycl-crt.${lib-suffix})
add_custom_command(OUTPUT ${devicelib-obj-file}
COMMAND ${clang} -fsycl -c
${compile_opts} ${sycl_targets_opt}
${CMAKE_CURRENT_SOURCE_DIR}/${lib_crt_source}
${CMAKE_CURRENT_SOURCE_DIR}/crt_wrapper.cpp
-o ${devicelib-obj-file}
MAIN_DEPENDENCY ${lib_crt_source}
MAIN_DEPENDENCY crt_wrapper.cpp
DEPENDS wrapper.h device.h spirv_vars.h clang clang-offload-bundler
VERBATIM)

Expand Down
14 changes: 13 additions & 1 deletion libdevice/msvc_wrapper.cpp → libdevice/crt_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//==--- msvc_wrapper.cpp - wrappers for Microsoft C library functions ------==//
//==------ crt_wrapper.cpp - wrappers for libc internal functions ----------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand All @@ -9,6 +9,7 @@
#include "wrapper.h"

#ifdef __SPIR__
#if defined(_WIN32)
// Truncates a wide (16 or 32 bit) string (wstr) into an ASCII string (str).
// Any non-ASCII characters are replaced by question mark '?'.
static void __truncate_wchar_char_str(const wchar_t *wstr, char *str,
Expand Down Expand Up @@ -37,4 +38,15 @@ void _wassert(const wchar_t *wexpr, const wchar_t *wfile, unsigned line) {
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(),
__spirv_LocalInvocationId_z());
}
#else
DEVICE_EXTERN_C
void __assert_fail(const char *expr, const char *file, unsigned int line,
const char *func) {
__devicelib_assert_fail(
expr, file, line, func, __spirv_GlobalInvocationId_x(),
__spirv_GlobalInvocationId_y(), __spirv_GlobalInvocationId_z(),
__spirv_LocalInvocationId_x(), __spirv_LocalInvocationId_y(),
__spirv_LocalInvocationId_z());
}
#endif
#endif // __SPIR__
21 changes: 0 additions & 21 deletions libdevice/glibc_wrapper.cpp

This file was deleted.