Skip to content

[bugfix] iOS: wordexp/wordfree unavailable and missing env() implementation#561

Open
uilianries wants to merge 2 commits into
boostorg:developfrom
uilianries:fix/ios-wordexp
Open

[bugfix] iOS: wordexp/wordfree unavailable and missing env() implementation#561
uilianries wants to merge 2 commits into
boostorg:developfrom
uilianries:fix/ios-wordexp

Conversation

@uilianries

Copy link
Copy Markdown

Greetings! 👋

When building Boost 1.91.0 on Mac M1 (aarch64) for iOS with Apple clang, it fails to build Boost.Process with two independent errors:

1. The functions wordexp and wordfree are unavailable on iOS

Apple iOS/tvOS/watchOS SDKs ship <wordexp.h> (inherited from the shared Apple SDK headers), but explicitly mark wordexp()/wordfree() as unavailable there:

    libs/process/src/shell.cpp:107:15: error: 'wordexp' is unavailable: not available on iOS
      107 |     auto cd = wordexp(input_.c_str(), &we, WRDE_NOCMD);
          |               ^
    .../iPhoneOS26.5.sdk/usr/include/wordexp.h:84:5: note: 'wordexp' has been
    explicitly marked unavailable here
       84 | int wordexp(const char * __restrict, wordexp_t * __restrict, int) __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_NA);
    libs/process/src/shell.cpp:124:9: error: 'wordfree' is unavailable: not available on iOS
    2 errors generated.

The full build error can be seen here: boost-1.91.0-ios-shared-process-wordexp.log

The shell.cpp already guards against __OpenBSD__ and __ANDROID__

https://github.com/boostorg/process/blob/boost-1.91.0/src/shell.cpp#L22

#elif !defined(__OpenBSD__) && !defined(__ANDROID__)
#include <wordexp.h>
#endif

Similar to #440, it's just missing the same guard for Apple's non-macOS targets like iphone.

The commit ecca6b2 extends that rule to include Apple platforms that are not darwin. We need to include TargetConditionals.h to make TARGET_OS_OSX available.

Reference: https://developer.apple.com/documentation/xcode/running-code-on-a-specific-version#Compile-code-for-a-specific-platform

2. Function ext::env is never defined for iOS

Once the commit ecca6b2 is applied, the previously mentioned error no longer occurs, but a new error shows later during the linkage stage:

	Undefined symbols for architecture arm64:
	  "boost::process::v2::ext::env(int, boost::system::error_code&)", referenced from:
	      boost::process::v2::ext::env(int) in env.o
	ld: symbol(s) not found for architecture arm64

You can see the build log with this error here: boost-1.91.0-ios-shared-process-env.log

The env.cpp already correctly excludes iOS with #elif (defined(__APPLE__) && defined(__MACH__)) && !TARGET_OS_IOS, but no replacement for ext::env was added for the iOS case, so on iOS execution falls through every #elif with none matching, the symbols result as undefined.

The commit beec496 adds an iOS-specific implementation of ext::env that returns ENOTSUP, mirroring OpenBSD/Android.

Both changes only affect Apple non-macOS targets; for b2, they are iphone and appletv. I validated both the shared and static link variants build on iOS 26.5 / Apple clang 21.0.0 with this patch applied to Boost 1.91.0. You can check my build logs with this patch:

Steps to Reproduce

wget https://archives.boost.io/release/1.91.0/source/boost_1_91_0.tar.bz2
tar jxf boost_1_91_0.tar.bz2 && cd boost_1_91_0/
./bootstrap.sh
./b2 install --prefix=/tmp/boost-install-ios --user-config=user-config.jam toolset=clang target-os=iphone architecture=arm address-model=64 abi=aapcs link=shared --with-process

My user-config.jam looks like:

using clang : : clang++ :
    <cflags>"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk -arch arm64 -mios-version-min=26.5"
    <cxxflags>"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk -arch arm64 -mios-version-min=26.5"
    <linkflags>"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.5.sdk -arch arm64 -mios-version-min=26.5" ;

Environment

  • Boost: 1.91.0
  • Host OS: macOS 26.5 (arm64)
  • Target OS: iOS 26.5
  • Compiler: Apple clang version 21.0.0 (clang-2100.1.1.101)

This PR is related to #401.

Feel free to ask for more information about this case if needed. Regards!

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant