macOS10.12/Xcode8 introduces run-time crash when building libcurl for earlier iOS versions #1069

Closed
bagder opened this Issue Oct 11, 2016 · 0 comments

Projects

None yet

1 participant

@bagder
Member
bagder commented Oct 11, 2016

Peter White reported the issue on the mailing list back in September. I'm filing it here so that it won't be forgotten. I've quoted a piece below.

A possible fix is to make the configure use the correct flags, as suggested by Martin Storsjö.

On macOS Sierra (v10.12) and iOS 10, the function clock_gettime has been introduced in the Darwin kernel. When building libcurl on macOS 10.12 with Xcode 8 and iOS10 SDK, the configure script will return yes for "monotonic clock_gettime" (around Line 20434 of configure).

However, when using libcurl in an application on an earlier version of iOS, this will cause a run time crash due to a missing symbol for clock_gettime.

No crash occurs on an iPhone 6 running iOS10, but on an iPad running iOS9.3.5, a crash occurs due to a missing symbol for clock_gettime.

@bagder bagder added a commit that closed this issue Oct 20, 2016
@bagder bagder configure: set min version flags for builds on mac
This helps building binaries that can work on multiple macOS versions.

Help-by: Martin Storsjö

Fixes #1069
4f8d0b6
@bagder bagder closed this in 4f8d0b6 Oct 20, 2016
@sitsofe sitsofe added a commit to sitsofe/fio that referenced this issue Feb 11, 2017
@sitsofe sitsofe configure: try and disable weak linking on OSX
macOS 10.12 introduces support for clock_gettime. Unfortunately when
compiling with XCode 8 (or later) and targeting 10.11 or older the
clock_gettime symbol will be found at configure/compile time and the
symbol will be referenced weakly. Running the binary on 10.11 results in
a "dyld: lazy symbol binding failed: Symbol not found: _clock_gettime"
error.

This drama has played out across other projects:
- Homebrew/homebrew-core#2674
- curl/curl#1069
- https://svn.filezilla-project.org/filezilla?view=revision&revision=7824OO
- mesonbuild/meson#949
- https://github.com/Homebrew/homebrew-core/issues?utf8=%E2%9C%93&q=label%3Aclock_gettime%20

Options for working around this issue include:
1. Turn references to symbols that might be weak into compilation
   errors (-Werror=partial-availability).
2. Disable visibility of symbols that might be weak
   (-Wl,-no_weak_imports).
3. Change configure tests to explictly fail by explictly checking if the
   targeted OSX is older than a version known to have the required symbol.

This commit tries 2. when targeting the Darwin platform after checking
if the compiler/linker work with that option.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
7c4d3ab
@sitsofe sitsofe added a commit to sitsofe/fio that referenced this issue Feb 11, 2017
@sitsofe sitsofe configure: try and disable weak linking on OSX
macOS 10.12 introduces support for clock_gettime. Unfortunately when
compiling with XCode 8 (or later) and targeting 10.11 or older the
clock_gettime symbol will be found at configure/compile time and the
symbol will be referenced weakly. Running the binary on 10.11 results in
a "dyld: lazy symbol binding failed: Symbol not found: _clock_gettime"
error.

This drama has played out across other projects:
- Homebrew/homebrew-core#2674
- curl/curl#1069
- https://svn.filezilla-project.org/filezilla?view=revision&revision=7824OO
- mesonbuild/meson#949
- https://github.com/Homebrew/homebrew-core/issues?utf8=%E2%9C%93&q=label%3Aclock_gettime%20

Options for working around this issue include:
1. Turn references to symbols that might be weak into compilation
   errors (-Werror=partial-availability).
2. Disable visibility of symbols that might be weak
   (-Wl,-no_weak_imports).
3. Change configure tests to explictly fail by explictly checking if the
   targeted OSX is older than a version known to have the required symbol.

This commit tries 2. when targeting the Darwin platform after checking
if the compiler/linker work with that option.

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
8517dbf
@sitsofe sitsofe added a commit to sitsofe/fio that referenced this issue Feb 12, 2017
@sitsofe sitsofe configure: try to disable weak linking on OSX
macOS 10.12 introduced support for clock_gettime() but when compiling
with Xcode 8 (or later) and targeting 10.11 (or older) the clock_gettime
symbol is now found at configure/compile time but referenced weakly.
Running the created binary on 10.11 results in a "dyld: lazy symbol
binding failed: Symbol not found: _clock_gettime" error.

This drama has played out across other projects:
- Homebrew/homebrew-core#2674
- curl/curl#1069
- https://svn.filezilla-project.org/filezilla?view=revision&revision=7824OO
- mesonbuild/meson#949
- https://github.com/Homebrew/homebrew-core/issues?utf8=%E2%9C%93&q=label%3Aclock_gettime%20

Options for working around this issue include:
1. Turn references to functions that might be weak into compilation
   errors (-Werror=partial-availability).
2. Disable visibility of functions that might be weak at compile link
   time (-Wl,-no_weak_imports).
3. Change configure tests to directly check the targeted OSX version and
   fail the test if it is too old to have the required function.
4. Make an empty function declaration marked with
   __attribute__((weak_import)) that is used if the symbol would
   otherwise be unavailable. It is then possible to check if the symbol
   is NULL at runtime to determine availability.

This commit does 2. when targeting the Darwin platform after checking if
the compiler/linker work with that option. It also changes the clockid_t
configure test to no longer use clock_gettime() because targeting OSX
10.11 when using the 10.12 SDK results in having clockid_t symbol
without having the clock_gettime function. The combination of these
fixes should solve axboe#305 .

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
fa75374
@sitsofe sitsofe added a commit to sitsofe/fio that referenced this issue Feb 13, 2017
@sitsofe sitsofe configure: try to disable weak linking on OSX
macOS 10.12 introduced support for clock_gettime() but when compiling
with Xcode 8 (or later) and targeting 10.11 (or older) the clock_gettime
symbol is now found at configure/compile time but referenced weakly.
Running the created binary on 10.11 results in a "dyld: lazy symbol
binding failed: Symbol not found: _clock_gettime" error.

This drama has played out across other projects:
- Homebrew/homebrew-core#2674
- curl/curl#1069
- https://svn.filezilla-project.org/filezilla?view=revision&revision=7824OO
- mesonbuild/meson#949
- https://github.com/Homebrew/homebrew-core/issues?utf8=%E2%9C%93&q=label%3Aclock_gettime%20

Options for working around this issue include:
1. Turn references to functions that might be weak into compilation
   errors (-Werror=partial-availability).
2. Disable visibility of functions that might be weak at compile link
   time (-Wl,-no_weak_imports).
3. Change configure tests to directly check the targeted OSX version and
   fail the test if it is too old to have the required function.
4. Make an empty function declaration marked with
   __attribute__((weak_import)) that is used if the symbol would
   otherwise be unavailable. It is then possible to check if the symbol
   is NULL at runtime to determine availability.

This commit does 2. when targeting the Darwin platform after checking if
the compiler/linker work with that option. It also changes the clockid_t
configure test to no longer use clock_gettime() because targeting OSX
10.11 when using the 10.12 SDK results in having the clockid_t typedef
without having the clock_gettime function. The combination of these
fixes should solve axboe#305 .

Signed-off-by: Sitsofe Wheeler <sitsofe@yahoo.com>
ccf2d89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment