All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
@ 2016-10-25  9:43 Liviu Ionescu
  2016-10-25 10:02 ` Peter Maydell
  2016-10-25 11:40 ` Paolo Bonzini
  0 siblings, 2 replies; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25  9:43 UTC (permalink / raw)
  To: qemu-devel

In Xcode 8 (more or less mandatory after upgrading to Sierra), Apple added support for `clock_gettime(CLOCK_MONOTONIC, &ts)`, which is not bad in itself.

Unfortunately, with this addition, a QEMU built on 10.12 runs **only** on 10.12; on previous versions it fails with something like:

```
$ ./qemu-system-gnuarmeclipse --version
dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
Referenced from: /Applications/GNU ARM Eclipse/QEMU/2.6.0-201610170917-dev/bin/./qemu-system-gnuarmeclipse (which was built for Mac OS X 10.12)
Expected in: /usr/lib/libSystem.B.dylib
```

The explanation is simple, for previous versions `_clock_gettime` is not available in the system library. 

Apple does some tricks with macros in `time.h` to specify that the definitions were introduced in 10.12, but QEMU uses only `#ifdef CLOCK_MONOTONIC` to select the use of `clock_gettime()`.

Until a more elaborate solution will be considered, my workaround was to replace `#ifdef CLOCK_MONOTONIC` with `#if defined(CLOCK_MONOTONIC) && !defined(__APPLE__)` and so avoid references to `clock_gettime()`.


Regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25  9:43 [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime() Liviu Ionescu
@ 2016-10-25 10:02 ` Peter Maydell
  2016-10-25 10:34   ` Liviu Ionescu
  2016-10-25 13:40   ` Liviu Ionescu
  2016-10-25 11:40 ` Paolo Bonzini
  1 sibling, 2 replies; 16+ messages in thread
From: Peter Maydell @ 2016-10-25 10:02 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel

On 25 October 2016 at 10:43, Liviu Ionescu <ilg@livius.net> wrote:
> In Xcode 8 (more or less mandatory after upgrading to Sierra), Apple added support for `clock_gettime(CLOCK_MONOTONIC, &ts)`, which is not bad in itself.
>
> Unfortunately, with this addition, a QEMU built on 10.12 runs **only** on 10.12; on previous versions it fails with something like:
>
> ```
> $ ./qemu-system-gnuarmeclipse --version
> dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
> Referenced from: /Applications/GNU ARM Eclipse/QEMU/2.6.0-201610170917-dev/bin/./qemu-system-gnuarmeclipse (which was built for Mac OS X 10.12)
> Expected in: /usr/lib/libSystem.B.dylib
> ```
>
> The explanation is simple, for previous versions `_clock_gettime` is not available in the system library.
>
> Apple does some tricks with macros in `time.h` to specify that the definitions were introduced in 10.12, but QEMU uses only `#ifdef CLOCK_MONOTONIC` to select the use of `clock_gettime()`.
>
> Until a more elaborate solution will be considered, my workaround was to replace `#ifdef CLOCK_MONOTONIC` with `#if defined(CLOCK_MONOTONIC) && !defined(__APPLE__)` and so avoid references to `clock_gettime()`.

Does "build on 10.12, run on earlier versions" work apart from
that problem?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 10:02 ` Peter Maydell
@ 2016-10-25 10:34   ` Liviu Ionescu
  2016-10-25 13:40   ` Liviu Ionescu
  1 sibling, 0 replies; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25 10:34 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel


> On 25 Oct 2016, at 13:02, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> ... Does "build on 10.12, run on earlier versions" work apart from
> that problem?

it is a challenge for me to test, since I don't have a 10.11 at hand; I'll try to have an answer in the evening, but I expect it'll work.

regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25  9:43 [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime() Liviu Ionescu
  2016-10-25 10:02 ` Peter Maydell
@ 2016-10-25 11:40 ` Paolo Bonzini
  2016-10-25 13:36   ` Liviu Ionescu
  1 sibling, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2016-10-25 11:40 UTC (permalink / raw)
  To: Liviu Ionescu, qemu-devel



On 25/10/2016 11:43, Liviu Ionescu wrote:
> In Xcode 8 (more or less mandatory after upgrading to Sierra), Apple added support for `clock_gettime(CLOCK_MONOTONIC, &ts)`, which is not bad in itself.
> 
> Unfortunately, with this addition, a QEMU built on 10.12 runs **only** on 10.12; on previous versions it fails with something like:
> 
> ```
> $ ./qemu-system-gnuarmeclipse --version
> dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
> Referenced from: /Applications/GNU ARM Eclipse/QEMU/2.6.0-201610170917-dev/bin/./qemu-system-gnuarmeclipse (which was built for Mac OS X 10.12)
> Expected in: /usr/lib/libSystem.B.dylib
> ```
> 
> The explanation is simple, for previous versions `_clock_gettime` is
> not available in the system library.
> 
> Apple does some tricks with macros in `time.h` to specify that the
> definitions were introduced in 10.12, but QEMU uses only `#ifdef
> CLOCK_MONOTONIC` to select the use of `clock_gettime()`.
> 
> Until a more elaborate solution will be considered, my workaround was
> to replace `#ifdef CLOCK_MONOTONIC` with `#if
> defined(CLOCK_MONOTONIC) && !defined(__APPLE__)` and so avoid
> references to `clock_gettime()`.

I think you need to use -mmacosx-version-min=10.10 or something like
that, using the configure flag --extra-cflags.

Paolo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 11:40 ` Paolo Bonzini
@ 2016-10-25 13:36   ` Liviu Ionescu
  2016-10-25 13:48     ` Paolo Bonzini
  0 siblings, 1 reply; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25 13:36 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


> On 25 Oct 2016, at 14:40, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> 
> ... I think you need to use -mmacosx-version-min=10.10 or something like
> that, ...

I tried this, and I also tried "export MACOSX_DEPLOYMENT_TARGET=10.11", but they did not help.

in this case, the decision to refer to `clock_gettime()` is made by `#ifdef CLOCK_MONOTONIC`, which seems to be always defined in <time.h> on 10.12.

if you want to test this, you can use:

cat <<EOF >/tmp/cg.c
#include <time.h>

#if defined(CLOCK_MONOTONIC)
#error CLOCK_MONOTONIC is defined
#endif
EOF

gcc /tmp/cg.c

gcc -mmacosx-version-min=10.11 /tmp/cg.c

MACOSX_DEPLOYMENT_TARGET=10.11; gcc /tmp/cg.c

...


if you find a combination of compiler options to prevent the error, then adding it to --extra-cflags might help.


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 10:02 ` Peter Maydell
  2016-10-25 10:34   ` Liviu Ionescu
@ 2016-10-25 13:40   ` Liviu Ionescu
  1 sibling, 0 replies; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25 13:40 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel


> On 25 Oct 2016, at 13:02, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> Does "build on 10.12, run on earlier versions" work apart from
> that problem?

with a little help from a friend, the latest macOS build for GNU ARM Eclipse QEMU seems fully functional, the STM32F4DISCOVERY blinky test blinks all 4 coloured leds.


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 13:36   ` Liviu Ionescu
@ 2016-10-25 13:48     ` Paolo Bonzini
  2016-10-25 14:12       ` Liviu Ionescu
  0 siblings, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2016-10-25 13:48 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel



On 25/10/2016 15:36, Liviu Ionescu wrote:
> I tried this, and I also tried "export MACOSX_DEPLOYMENT_TARGET=10.11", but they did not help.
> 
> in this case, the decision to refer to `clock_gettime()` is made by `#ifdef CLOCK_MONOTONIC`, which seems to be always defined in <time.h> on 10.12.
> 
> if you want to test this, you can use:
> 
> cat <<EOF >/tmp/cg.c
> #include <time.h>
> 
> #if defined(CLOCK_MONOTONIC)
> #error CLOCK_MONOTONIC is defined
> #endif
> EOF
> 
> gcc /tmp/cg.c
> 
> gcc -mmacosx-version-min=10.11 /tmp/cg.c
> 
> MACOSX_DEPLOYMENT_TARGET=10.11; gcc /tmp/cg.c
> 
> ...
> 
> 
> if you find a combination of compiler options to prevent the error, then adding it to --extra-cflags might help.

Perhaps you can add a configure test for clock_gettime, and define a
symbol CONFIG_HAVE_CLOCK_GETTIME if clock_gettime exists.

If needed, include the appropriate attribute in the test:

#include <time.h>
#if defined __clang__ && defined __APPLE__
__attribute__((availability(macos,strict,introduced=10.12)))
int clock_gettime(clockid_t clk_id, struct timespec *tp);
#endif

Then change QEMU to use clock_gettime() only

#if defined CONFIG_HAVE_CLOCK_GETTIME && defined CLOCK_MONOTONIC

Paolo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 13:48     ` Paolo Bonzini
@ 2016-10-25 14:12       ` Liviu Ionescu
  2016-10-25 14:21         ` Paolo Bonzini
  0 siblings, 1 reply; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25 14:12 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


> On 25 Oct 2016, at 16:48, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> Perhaps you can add a configure test for clock_gettime, and define a
> symbol CONFIG_HAVE_CLOCK_GETTIME if clock_gettime exists.

I thought of this, but if I run the build on 10.12, configure will identify `clock_gettime()` as present, refer to it, and when the executable is started on 10.11, it'll fail. :-(


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 14:12       ` Liviu Ionescu
@ 2016-10-25 14:21         ` Paolo Bonzini
  2016-10-25 14:37           ` Liviu Ionescu
  0 siblings, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2016-10-25 14:21 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel



On 25/10/2016 16:12, Liviu Ionescu wrote:
> 
>> On 25 Oct 2016, at 16:48, Paolo Bonzini <pbonzini@redhat.com>
>> wrote:
>> 
>> Perhaps you can add a configure test for clock_gettime, and define
>> a symbol CONFIG_HAVE_CLOCK_GETTIME if clock_gettime exists.
> 
> I thought of this, but if I run the build on 10.12, configure will
> identify `clock_gettime()` as present, refer to it, and when the
> executable is started on 10.11, it'll fail. :-(

If you add the attribute to the test, configure will detect it or not
depending on -mmacosx-version-min, at least in theory.

Paolo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 14:21         ` Paolo Bonzini
@ 2016-10-25 14:37           ` Liviu Ionescu
  2016-10-25 14:38             ` Paolo Bonzini
  0 siblings, 1 reply; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-25 14:37 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel


> On 25 Oct 2016, at 17:21, Paolo Bonzini <pbonzini@redhat.com> wrote:
> 
> ... If you add the attribute to the test, configure will detect it or not
> depending on -mmacosx-version-min, at least in theory.

aha. so your suggestion is to extend configure to add CONFIG_HAVE_CLOCK_GETTIME, add -mmacosx-version-min to be sure configure does **not** set CONFIG_HAVE_CLOCK_GETTIME, and then patch the source codes to conditionally refer to clock_gettime().

this is definitely a better approach than my workaround, but requires much more effort. I'll probably wait for such a solution, when available.


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-25 14:37           ` Liviu Ionescu
@ 2016-10-25 14:38             ` Paolo Bonzini
  0 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2016-10-25 14:38 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel



On 25/10/2016 16:37, Liviu Ionescu wrote:
>>> ... If you add the attribute to the test, configure will detect
>>> it or not depending on -mmacosx-version-min, at least in theory.
> aha. so your suggestion is to extend configure to add
> CONFIG_HAVE_CLOCK_GETTIME, add -mmacosx-version-min to be sure
> configure does **not** set CONFIG_HAVE_CLOCK_GETTIME, and then patch
> the source codes to conditionally refer to clock_gettime().
> 
> this is definitely a better approach than my workaround, but requires
> much more effort. I'll probably wait for such a solution, when
> available.

You'll have to wait for a long time, since I don't even have a computer
to test it on.

Paolo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-26 15:39       ` Liviu Ionescu
@ 2016-10-26 16:03         ` G 3
  0 siblings, 0 replies; 16+ messages in thread
From: G 3 @ 2016-10-26 16:03 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel qemu-devel, Paolo Bonzini


On Oct 26, 2016, at 11:39 AM, Liviu Ionescu wrote:

>
>> On 26 Oct 2016, at 18:32, G 3 <programmingkidx@gmail.com> wrote:
>>
>> -isysroot /Developer/SDKs/MacOSX10.6.sdk
>
> yes, this is a compiler command line option pointing to an existing  
> folder, but `/Developer/` is no longer in use for quite some time,  
> and Apple does not provide any official way to install previous SDK  
> versions.
>
>
> regards,
>
> Liviu

What SDK's does your version of Xcode come with. When installing  
Xcode, there is usually an option to install other SDK versions.  
Could you try checking the Xcode installer?

https://github.com/phracker/MacOSX-SDKs/releases
This is what you want.

Good luck

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-26 15:32     ` G 3
@ 2016-10-26 15:39       ` Liviu Ionescu
  2016-10-26 16:03         ` G 3
  0 siblings, 1 reply; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-26 15:39 UTC (permalink / raw)
  To: G 3; +Cc: qemu-devel qemu-devel, Paolo Bonzini


> On 26 Oct 2016, at 18:32, G 3 <programmingkidx@gmail.com> wrote:
> 
> -isysroot /Developer/SDKs/MacOSX10.6.sdk

yes, this is a compiler command line option pointing to an existing folder, but `/Developer/` is no longer in use for quite some time, and Apple does not provide any official way to install previous SDK versions.


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-26 15:15   ` Liviu Ionescu
@ 2016-10-26 15:32     ` G 3
  2016-10-26 15:39       ` Liviu Ionescu
  0 siblings, 1 reply; 16+ messages in thread
From: G 3 @ 2016-10-26 15:32 UTC (permalink / raw)
  To: Liviu Ionescu; +Cc: qemu-devel qemu-devel, Paolo Bonzini


On Oct 26, 2016, at 11:15 AM, Liviu Ionescu wrote:

>
>> On 26 Oct 2016, at 17:32, G 3 <programmingkidx@gmail.com> wrote:
>>
>> Maybe changing the base SDK from Mac OS 10.12 to say Mac OS 10.6  
>> might fix the problem.
>
> any suggestion how to do this?
>
> for my linux and windows builds I use docker images, and I'm quite  
> happy with this setup, it is stable and I get the same results  
> regardless the environment I use to run the builds.
>
> unfortunately, for macOS, my development platform, I do not have a  
> stable, fully controllable, build platform, and each time Apple  
> updates the system I run into problems.
>
> currently deep inside Xcode 8 is OSX 10.12 SDK only, and I do not  
> know how to install other versions.
>
> I'm considering a custom homebrew install, with all specific tools,  
> but, as far as I know, this will not completely severe the links to  
> the system libraries.
>
>
> so any suggestions on how to stick to a specific base SDK will be  
> highly appreciated.
>
>
> regards,
>
> Liviu

I think the isysroot command-line option is what you would use.  
Something like this: -isysroot /Developer/SDKs/MacOSX10.6.sdk

This link has some more info:
http://stackoverflow.com/questions/2279499/isysroot-or-sdkroot-problem

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
  2016-10-26 14:32 ` G 3
@ 2016-10-26 15:15   ` Liviu Ionescu
  2016-10-26 15:32     ` G 3
  0 siblings, 1 reply; 16+ messages in thread
From: Liviu Ionescu @ 2016-10-26 15:15 UTC (permalink / raw)
  To: G 3; +Cc: qemu-devel qemu-devel, Paolo Bonzini


> On 26 Oct 2016, at 17:32, G 3 <programmingkidx@gmail.com> wrote:
> 
> Maybe changing the base SDK from Mac OS 10.12 to say Mac OS 10.6 might fix the problem.

any suggestion how to do this?

for my linux and windows builds I use docker images, and I'm quite happy with this setup, it is stable and I get the same results regardless the environment I use to run the builds.

unfortunately, for macOS, my development platform, I do not have a stable, fully controllable, build platform, and each time Apple updates the system I run into problems.

currently deep inside Xcode 8 is OSX 10.12 SDK only, and I do not know how to install other versions.
 
I'm considering a custom homebrew install, with all specific tools, but, as far as I know, this will not completely severe the links to the system libraries.


so any suggestions on how to stick to a specific base SDK will be highly appreciated.


regards,

Liviu

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime()
       [not found] <mailman.12713.1477406219.22738.qemu-devel@nongnu.org>
@ 2016-10-26 14:32 ` G 3
  2016-10-26 15:15   ` Liviu Ionescu
  0 siblings, 1 reply; 16+ messages in thread
From: G 3 @ 2016-10-26 14:32 UTC (permalink / raw)
  To: qemu-devel qemu-devel; +Cc: Paolo Bonzini, Liviu Ionescu


On Oct 25, 2016, at 10:36 AM, qemu-devel-request@nongnu.org wrote:

> Message: 1
> Date: Tue, 25 Oct 2016 17:12:22 +0300
> From: Liviu Ionescu <ilg@livius.net>
> To: Paolo Bonzini <pbonzini@redhat.com>
> Cc: qemu-devel <Qemu-devel@nongnu.org>
> Subject: Re: [Qemu-devel] macOS 10.12 Sierra, Xcode 8 &
> 	clock_gettime()
> Message-ID: <704CB7E1-45BE-4386-9029-9BD70A30F7E8@livius.net>
> Content-Type: text/plain; charset=us-ascii
>
>
>> On 25 Oct 2016, at 16:48, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>
>> Perhaps you can add a configure test for clock_gettime, and define a
>> symbol CONFIG_HAVE_CLOCK_GETTIME if clock_gettime exists.
>
> I thought of this, but if I run the build on 10.12, configure will  
> identify `clock_gettime()` as present, refer to it, and when the  
> executable is started on 10.11, it'll fail. :-(
>
>
> regards,
>
> Liviu

Maybe changing the base SDK from Mac OS 10.12 to say Mac OS 10.6  
might fix the problem.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2016-10-26 16:04 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25  9:43 [Qemu-devel] macOS 10.12 Sierra, Xcode 8 & clock_gettime() Liviu Ionescu
2016-10-25 10:02 ` Peter Maydell
2016-10-25 10:34   ` Liviu Ionescu
2016-10-25 13:40   ` Liviu Ionescu
2016-10-25 11:40 ` Paolo Bonzini
2016-10-25 13:36   ` Liviu Ionescu
2016-10-25 13:48     ` Paolo Bonzini
2016-10-25 14:12       ` Liviu Ionescu
2016-10-25 14:21         ` Paolo Bonzini
2016-10-25 14:37           ` Liviu Ionescu
2016-10-25 14:38             ` Paolo Bonzini
     [not found] <mailman.12713.1477406219.22738.qemu-devel@nongnu.org>
2016-10-26 14:32 ` G 3
2016-10-26 15:15   ` Liviu Ionescu
2016-10-26 15:32     ` G 3
2016-10-26 15:39       ` Liviu Ionescu
2016-10-26 16:03         ` G 3

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.