This helps to avoid compilation errors like
lib/sanitizer_common/sanitizer_mac.cpp:617:7: error: use of undeclared identifier 'TARGET_OS_IOS' if (TARGET_OS_IOS || TARGET_OS_TV) return 6; ^
Differential D103598
[Darwin][compiler-rt] Test TARGET_OS_* conditionals using preprocessor directives veprbl on Jun 3 2021, 1:50 AM. Authored by
Details
Diff Detail
Event TimelineComment Actions Hi Dmitry, I am happy with the quality of this patch, but I don't understand why it is required. These constant are defined in TargetConditionals.h (included via sanitizer_common/sanitizer_platform.h) which is part of the Apple SDK and should always be available. Comment Actions I can give some clarifications. The environment which I'm using is based on Nix/Nixpkgs where we are packaging our own SDK based on what is available from the open source releases that were done by Apple. Originally I googled the issue with the defines and saw that people outside of LLVM and Nix had similar issues, so I assumed it was a common issue with perhaps a slightly outdated SDK (we are using 10.12). Your response had prompted me to investigate this a little bit more, and by running the compiler with a nice -H option I learned that the particular instance of TargetConditionals.h that was using in compiler-rt's compilation wasn't coming from the SDK or the Swift CF framework. Instead it was coming from a hardcoded file [1] that may have been based on some SDK at the time, but definitely have not been updated in 6 years and is missing some of the definitions that are currently needed to build the compiler-rt. I'm not really sure about all the moving parts involved, but, I think, I could try to fix the issue by updating TargetConditionals.h on our end. Comment Actions Looking at the TargetConditionals.h from our 10.12 SDK, I see that there are actually branches that lead to some of the TARGET_OS_ definitions staying undefined for non-apple compilers, so it seems like this patch has some merit to it. |