mesat opened a new pull request, #49654:
URL: https://github.com/apache/doris/pull/49654

   - Explicitly define _DARWIN_C_SOURCE to expose system definitions.
   - Introduce compatibility header (macos_uuid_fix.h) for conditional 
definition of uuid_string_t.
   - Refactor affected macOS source files to include the compatibility header.
   
   This addresses build failures caused by Apple's removal of implicit 
uuid_string_t definitions in recent macOS SDK versions.
   
   ### What problem does this PR solve?
   
   **Problem**
   On macOS 10.14 and later SDKs, building thirdpary can fail with an exception 
:
   
   ```
   error: unknown type name 'uuid_string_t'
   ```
   The exception message:
   ```
   [61/310] Building CXX object 
src/CMakeFiles/BUTIL_LIB.dir/butil/file_util_posix.cc.o
   FAILED: src/CMakeFiles/BUTIL_LIB.dir/butil/file_util_posix.cc.o 
   /opt/homebrew/opt/llvm@16/bin/clang++  
-I/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src
 
-I/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/doris_build
 
-I/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/installed/include
 
-I/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/doris_build/src
 -Wno-deprecated-declarations -Wno-inconsistent-missing-override  
-DBRPC_WITH_GLOG=1 -DBRPC_WITH_RDMA=0 -DGFLAGS_NS=google 
-DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__=__unused__ -D_GNU_SOURCE 
-DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-D__STDC_CONSTANT_MACROS 
-DBRPC_REVISION=\"1.4.0\|master\|7e3c475d51\|2025-03-04T21:06:46+08:00\" 
-D__STRICT_ANSI__ -g  -O2 -pipe -Wall -W -fPIC -fstrict-aliasing 
-Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -DNDEBUG 
-std=gnu++11 -arch arm64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/Ma
 cOSX.platform/Developer/SDKs/MacOSX15.2.sdk -MD -MT 
src/CMakeFiles/BUTIL_LIB.dir/butil/file_util_posix.cc.o -MF 
src/CMakeFiles/BUTIL_LIB.dir/butil/file_util_posix.cc.o.d -o 
src/CMakeFiles/BUTIL_LIB.dir/butil/file_util_posix.cc.o -c 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/file_util_posix.cc
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/file_util_posix.cc:26:
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/mac/foundation_util.h:32:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/hfs/hfs_format.h:807:2:
 error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
           uuid_string_t   ext_jnl_uuid;
           ^
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/device/device_types.h:89:33:
 note: 'io_string_t' declared here
   typedef char                    io_string_t[512];
                                   ^
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/file_util_posix.cc:26:
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/mac/foundation_util.h:32:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/hfs/hfs_format.h:809:20:
 error: unknown type name 'uuid_string_t'; did you mean 'io_string_t'?
           char            reserved[JIB_RESERVED_SIZE];
                                    ^
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/hfs/hfs_format.h:800:61:
 note: expanded from macro 'JIB_RESERVED_SIZE'
   #define JIB_RESERVED_SIZE  ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 
48)
                                                               ^
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/device/device_types.h:89:33:
 note: 'io_string_t' declared here
   typedef char                    io_string_t[512];
                                   ^
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/file_util_posix.cc:26:
   In file included from 
/Users/msakarya/Repository/doris/doris-project/doris/thirdparty/src/brpc-1.4.0/src/butil/mac/foundation_util.h:32:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:23:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:208:
   In file included from 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/HFSVolumes.h:25:
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/hfs/hfs_format.h:809:20:
 error: array is too large (18446744073709551184 elements)
           char            reserved[JIB_RESERVED_SIZE];
                                    ^~~~~~~~~~~~~~~~~
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/hfs/hfs_format.h:800:28:
 note: expanded from macro 'JIB_RESERVED_SIZE'
   #define JIB_RESERVED_SIZE  ((32*sizeof(u_int32_t)) - sizeof(uuid_string_t) - 
48)
                              
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   3 errors generated.
   [63/310] Building CXX object src/CMakeFiles/BUTIL_LIB.dir/butil/location.cc.o
   ninja: build stopped: subcommand failed.
   ```
   
   Original Situation (Older SDK Versions): In earlier macOS SDK versions 
(prior to approximately macOS 10.14), the uuid_string_t type was consistently 
defined by Apple within the SDK header files (specifically <uuid/uuid.h>). 
Therefore, simply including standard headers from Apple's frameworks 
automatically provided this type.
   
   Change in macOS SDK (Newer Versions): In more recent macOS SDKs (e.g., 11.x, 
12.x, and onward), Apple modified or tightened internal header dependencies. 
The file /usr/include/hfs/hfs_format.h now references the type uuid_string_t 
directly, but no longer guarantees inclusion of <uuid/uuid.h>. As a result, 
when compiling projects that include these headers indirectly through 
frameworks (like CoreServices), the compiler encounters uuid_string_t without a 
valid definition.
   
   Underlying Reason: The core issue is Apple's restructuring and cleanup of 
internal header files. Apple expects projects to explicitly include 
<uuid/uuid.h> themselves if uuid_string_t is used directly or indirectly. Thus, 
relying on indirect inclusion through other headers or frameworks no longer 
works reliably.
   
   Previous Behavior
   
   On macOS SDK 10.14+, third-party builds would fail due to the missing 
uuid_string_t definition, causing compilation to stop with the “unknown type 
name 'uuid_string_t'” error.
   
   New Behavior
   
   The build now completes successfully on macOS 10.14+ because 
_DARWIN_C_SOURCE is properly defined and uuid_string_t is explicitly made 
available.
   
   Why Modified
   
   To fix the repeated build failures on modern macOS systems and ensure Doris 
can compile third-party cleanly across different macOS SDK versions.
   
   Potential Impacts
   
   No impact on earlier macOS versions or on non-macOS systems. The fix only 
applies if the detected SDK version is 10.14 or higher.
   
   **Solution**
   
   **Which code was refactored and why was this part of the code refactored?**
   Several existing macOS-specific source files (bundle_locations.mm, 
foundation_util.h/mm, platform_thread_mac.mm, file_util_mac.mm, and 
sys_string_conversions_mac.mm) were refactored slightly by adding an explicit 
inclusion of the new compatibility header (macos_uuid_fix.h). The purpose of 
this minimal refactoring was to consolidate the fix in a single place, 
simplifying future maintenance and clearly communicating the intention of 
addressing the SDK compatibility issue across multiple files, rather than 
repeatedly patching individual locations.
   
   Detect the macOS SDK version at CMake configure time (xcrun --sdk macosx 
--show-sdk-version).
   
   If the SDK version is 10.14 or newer, define _DARWIN_C_SOURCE and 
USE_DARWIN_UUID_FIX.
   
   Introduce a new header, macos_uuid_fix.h, which conditionally redefines 
uuid_string_t when _DARWIN_C_SOURCE is needed.
   
   With this approach, the uuid_string_t type is properly declared, and the 
compilation error is resolved.
   
   Issue Number: close #xxx
   
   Related PR: #xxx
   
   Problem Summary:
   
   ### Release note
   
   None
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [ ] Regression test
       - [ ] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason <!-- Add your reason?  -->
   
   - Behavior changed:
       - [ ] No.
       - [ ] Yes. <!-- Explain the behavior change -->
   
   - Does this need documentation?
       - [ ] No.
       - [ ] Yes. <!-- Add document PR link here. eg: 
https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should 
merge into -->
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to