[llvm] [SYCL] Add libsycl, a SYCL RT library implementation project (PR #144372)
Nikolas Klauser via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 21 10:49:42 PDT 2025
================
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of the macros defining attributes for
+/// exported methods and defining API namespaces.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef __LIBSYCL_DETAIL_CONFIG_HPP
+#define __LIBSYCL_DETAIL_CONFIG_HPP
+
+#include <sycl/version.hpp>
+
+#define __LIBSYCL_BEGIN_UNVERSIONED_NAMESPACE namespace sycl {
+#define __LIBSYCL_END_UNVERSIONED_NAMESPACE }
+
+#define __LIBSYCL_BEGIN_VERSIONED_NAMESPACE \
+ __LIBSYCL_BEGIN_UNVERSIONED_NAMESPACE inline namespace __LIBSYCL_ABI_NAMESPACE {
+#define __LIBSYCL_END_VERSIONED_NAMESPACE \
+ } \
+ __LIBSYCL_END_UNVERSIONED_NAMESPACE
+
+#ifndef __SYCL_DEVICE_ONLY__
+#ifndef __LIBSYCL_EXPORT
+#ifdef _WIN32
+
+#define __LIBSYCL_DLL_LOCAL
+
+#if __LIBSYCL_BUILD_SYCL_DLL
+#define __LIBSYCL_EXPORT __declspec(dllexport)
+#define __LIBSYCL_EXPORT_DEPRECATED(x) __declspec(dllexport, deprecated(x))
+#else
+#define __LIBSYCL_EXPORT __declspec(dllimport)
+#define __LIBSYCL_EXPORT_DEPRECATED(x) __declspec(dllimport, deprecated(x))
+#endif //__LIBSYCL_BUILD_SYCL_DLL
+
+#else // _WIN32
+
+#define __LIBSYCL_DLL_LOCAL __attribute__((visibility("hidden")))
----------------
philnik777 wrote:
I tend to prefer `[[]]` because it makes the positions an attribute can be in a lot more predictable. `__visibility__` should be preferred over `visibility` because the latter can clash with user `#define`s, which the former cannot. In this case it probably doesn't make much of a difference, but having a single rule for all attributes is a lot less complicated than different rules depending on how likely it is for a name clash. You have it behind a macro anyways, so I don't see the downside.
https://github.com/llvm/llvm-project/pull/144372
More information about the llvm-commits
mailing list