Skip to content

Commit

Permalink
Merge pull request #1079 from marktucker/dev_windows_clangcl
Browse files Browse the repository at this point in the history
Fixes for calling into a USD library built with MSVC, from code built with clang-cl

(Internal change: 2039781)
  • Loading branch information
pixar-oss committed Feb 7, 2020
2 parents e910a9d + de08485 commit c5c7d49
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
22 changes: 11 additions & 11 deletions pxr/base/arch/attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@ struct Arch_ConstructorEntry {
}; \
static void _name(__VA_ARGS__)

#elif defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG)

// The used attribute is required to prevent these apparently unused functions
// from being removed by the linker.
# define ARCH_CONSTRUCTOR(_name, _priority, ...) \
__attribute__((used, section(".pxrctor"), constructor((_priority) + 100))) \
static void _name(__VA_ARGS__)
# define ARCH_DESTRUCTOR(_name, _priority, ...) \
__attribute__((used, section(".pxrdtor"), destructor((_priority) + 100))) \
static void _name(__VA_ARGS__)

#elif defined(ARCH_OS_WINDOWS)

# include "pxr/base/arch/api.h"
Expand Down Expand Up @@ -312,17 +323,6 @@ struct Arch_ConstructorInit {
_ARCH_ENSURE_PER_LIB_INIT(Arch_ConstructorInit, _archCtorInit); \
static void _name(__VA_ARGS__)

#elif defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG)

// The used attribute is required to prevent these apparently unused functions
// from being removed by the linker.
# define ARCH_CONSTRUCTOR(_name, _priority, ...) \
__attribute__((used, section(".pxrctor"), constructor((_priority) + 100))) \
static void _name(__VA_ARGS__)
# define ARCH_DESTRUCTOR(_name, _priority, ...) \
__attribute__((used, section(".pxrdtor"), destructor((_priority) + 100))) \
static void _name(__VA_ARGS__)

#else

// Leave macros undefined so we'll fail to build on a new system/compiler
Expand Down
6 changes: 3 additions & 3 deletions pxr/base/tf/preprocessorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/tuple/to_list.hpp>
#include <boost/preprocessor/tuple/to_seq.hpp>
#if defined(ARCH_OS_WINDOWS)
#if defined(ARCH_COMPILER_MSVC)
#include <boost/preprocessor/variadic/size.hpp>
#include <boost/vmd/is_empty.hpp>
#include <boost/vmd/is_tuple.hpp>
Expand All @@ -66,7 +66,7 @@ ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
///
/// \ingroup group_tf_Preprocessor
/// \hideinitializer
#if defined(ARCH_OS_WINDOWS)
#if defined(ARCH_COMPILER_MSVC)
#define TF_NUM_ARGS(...) \
BOOST_PP_IIF(BOOST_VMD_IS_EMPTY(__VA_ARGS__),\
0, BOOST_PP_VARIADIC_SIZE(__VA_ARGS__))
Expand Down Expand Up @@ -189,7 +189,7 @@ ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
/// Exapnds to 1 if the argument is a tuple, and 0 otherwise.
/// \ingroup group_tf_Preprocessor
/// \hideinitializer
#if defined(ARCH_OS_WINDOWS)
#if defined(ARCH_COMPILER_MSVC)
#define TF_PP_IS_TUPLE(sequence) \
BOOST_VMD_IS_TUPLE(sequence)
#else
Expand Down
2 changes: 0 additions & 2 deletions pxr/usd/ar/asset.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ class ArAsset {
AR_API
virtual ~ArAsset();

AR_API
ArAsset(const ArAsset&) = delete;

AR_API
ArAsset& operator=(const ArAsset&) = delete;

/// Returns size of the asset.
Expand Down
4 changes: 2 additions & 2 deletions pxr/usd/sdf/fileFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class SdfFileFormat : public TfRefBase, public TfWeakBase, boost::noncopyable
const SdfSchemaBase& schema);

/// Disallow temporary SdfSchemaBase objects being passed to the c'tor.
SDF_API SdfFileFormat(
SdfFileFormat(
const TfToken& formatId,
const TfToken& versionString,
const TfToken& target,
Expand All @@ -280,7 +280,7 @@ class SdfFileFormat : public TfRefBase, public TfWeakBase, boost::noncopyable
const SdfSchemaBase& schema);

/// Disallow temporary SdfSchemaBase objects being passed to the c'tor.
SDF_API SdfFileFormat(
SdfFileFormat(
const TfToken& formatId,
const TfToken& versionString,
const TfToken& target,
Expand Down

0 comments on commit c5c7d49

Please sign in to comment.