View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0033243 | Community | OCCT:Coding | public | 2022-11-30 19:30 | 2022-12-04 02:51 |
Reporter | blobfish | Assigned To | kgv | ||
Priority | normal | Severity | minor | ||
Status | new | Resolution | open | ||
Platform | Mac | OS | OS | ||
Product Version | 7.6.3 | ||||
Summary | 0033243: Invalid build or use of occt on macosx in specific case | ||||
Description | I have successfully built and installed occt on macosx big-sur. In another project that uses occt, I have another library that can't build using the clang default config. I had to cheat gnuc version that clang was pretending to be by creating an environment variable, CXXFLAGS=-fgnuc-version=7.0. With that variable occt will fail with: /src/Standard/Standard_Type.hxx:34:10: fatal error: 'tr2/type_traits' file not found. That variable will cause a build failure of occt itself. There are 2 problems here 1) the __GNUC__ macros don't behave as expected. 2) the path to the type_traits file isn't valid. The first problem has been hiding the second. | ||||
Steps To Reproduce | export CXXFLAGS=-fgnuc-version=7.0 cmake "OCCT BUILD ARGUMENTS" make | ||||
Additional information and documentation updates | result of find for type_traits file: ./usr/local/Cellar/llvm/15.0.5/include/c++/v1/experimental/type_traits ./usr/local/Cellar/llvm/15.0.5/include/c++/v1/type_traits ./Library/Developer/CommandLineTools/usr/include/c++/v1/experimental/type_traits ./Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits ./Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/experimental/type_traits ./Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/type_traits ./Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/experimental/type_traits ./Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/type_traits ./System/Volumes/Data/usr/local/Cellar/llvm/15.0.5/include/c++/v1/experimental/type_traits ./System/Volumes/Data/usr/local/Cellar/llvm/15.0.5/include/c++/v1/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/usr/include/c++/v1/experimental/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/experimental/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/c++/v1/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/experimental/type_traits ./System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/usr/include/c++/v1/type_traits Did the tr1 folder get renamed to v1 on mac sometime in the past? Apparently clang always sets the __GNUC__ macros to equal version 4.2. Meaning your more modern code path is never reached with clang, without a hack like mine. Maybe replace __GNUC__ with the more cross platform __cplusplus. Or add some clang conditionals into the mix. Test: #include <iostream> int main(int,char**) { std::cout << "__GNUC__ = " << __GNUC__ << std::endl; std::cout << "__GNUC_MINOR__ = " << __GNUC_MINOR__ << std::endl; std::cout << "clang: " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__ << std::endl; std::cout << "__cplusplus " << __cplusplus << std::endl; } //no environment hack used for any results. //apple clang bigsur@bigsurs-iMac-Pro test % g++ main.cpp -o test bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 13.0.0 __cplusplus 199711 //apple clang c++11 bigsur@bigsurs-iMac-Pro test % g++ main.cpp -o test -std=c++11 bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 13.0.0 __cplusplus 201103 //apple clang c++14 bigsur@bigsurs-iMac-Pro test % g++ main.cpp -o test -std=c++14 bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 13.0.0 __cplusplus 201402 //apple clang c++17 bigsur@bigsurs-iMac-Pro test % g++ main.cpp -o test -std=c++17 bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 13.0.0 __cplusplus 201703 //homebrew clang bigsur@bigsurs-iMac-Pro test % clang++ main.cpp -o test bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 15.0.5 __cplusplus 201402 //homebrew clang c++17 bigsur@bigsurs-iMac-Pro test % clang++ main.cpp -o test -std=c++17 bigsur@bigsurs-iMac-Pro test % ./test __GNUC__ = 4 __GNUC_MINOR__ = 2 clang: 15.0.5 __cplusplus 201703 | ||||
Tags | No tags attached. | ||||
Test case number | |||||
|
Ah. The directory discrepancy is probably libc++ vs libstdc++. |
|
FYI: I got through my build expanding preprocessor condition to include clang. You guys can close this issue if you want. diff --git a/src/Standard/Standard_Type.hxx b/src/Standard/Standard_Type.hxx index 65b6826a81..561eb91fe8 100644 --- a/src/Standard/Standard_Type.hxx +++ b/src/Standard/Standard_Type.hxx @@ -26,7 +26,7 @@ // DEFINE_STANDARD_RTTI* macro is actually a base class. #if ! defined(OCCT_CHECK_BASE_CLASS) -#if (defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4))) +#if (! defined(__clang__) && defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4))) // For GCC 4.7+, more strict check is possible -- ensuring that base class // is direct base -- using non-standard C++ reflection functionality. |