Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native: build of vtimer_msg test fails on OS X #3175

Closed
emmanuelsearch opened this issue Jun 8, 2015 · 4 comments
Closed

Native: build of vtimer_msg test fails on OS X #3175

emmanuelsearch opened this issue Jun 8, 2015 · 4 comments
Assignees
Labels
OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system Platform: native Platform: This PR/issue effects the native platform Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)

Comments

@emmanuelsearch
Copy link
Member

Build of vtimer_msg test fails on OS X with current master.

Error is:

In file included from /RIOT/cpu/native/hwtimer_cpu.c:47:
In file included from /RIOT/RIOT/core/include/debug.h:34:
/RIOT/core/include/thread.h:138:14: error: conflicting types for 'thread_create'
kernel_pid_t thread_create(char *stack,
             ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/mach/task.h:193:15: note: 
      previous declaration is here
kern_return_t thread_create
              ^
1 error generated.

Toolchain info:

OS X version 10.10.3
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.3.0
Thread model: posix
@LudwigKnuepfer LudwigKnuepfer added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Platform: native Platform: This PR/issue effects the native platform OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system labels Jun 9, 2015
@LudwigKnuepfer LudwigKnuepfer self-assigned this Jun 9, 2015
@josephnoir
Copy link
Contributor

Same for me in the thread_* tests.

$ clang -v
OS X 10.10.4 (14E26a)
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
´´´

@ximus
Copy link
Contributor

ximus commented Jun 15, 2015

This also happens when running the entire test suite cd tests/unittests && make
My output is slightly different (different location of task.h), but essentially the same error:

~/c/R/t/unittests (master) $ make
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Building application "unittests" for "native" with MCU "native".

touch /Users/me/code/RIOT/tests/unittests/main.c
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/boards/native
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/boards/native/drivers
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/core
"/Applications/Xcode.app/Contents/Developer/usr/bin/make" -C /Users/me/code/RIOT/cpu/native
In file included from /Users/me/code/RIOT/cpu/native/hwtimer_cpu.c:47:
In file included from /Users/me/code/RIOT/core/include/debug.h:34:
/Users/me/code/RIOT/core/include/thread.h:138:14: error: conflicting types for 'thread_create'
kernel_pid_t thread_create(char *stack,
             ^
/usr/include/mach/task.h:193:15: note: previous declaration is here
kern_return_t thread_create
              ^
1 error generated.
make[2]: *** [/Users/me/code/RIOT/tests/unittests/bin/native/cpu/hwtimer_cpu.o] Error 1
make[1]: *** [ALL--/Users/me/code/RIOT/cpu/native] Error 2
make: *** [all] Error 2

The issue is cpu/native/hwtimer_cpu.c on OSX includes mach/mach.h which includes mach/mach_interface.h which includes mach/task.h which defines thread_create() which conflicts with Riot's own thread_create().

I see two solutions:

  • Rename the conflicting method(s). Downside is thread_create() is a good and established name.
  • Rework the mach dependencies, which is possible. This works for the time being. I was able to get past the error with the following change:
diff --git a/cpu/native/hwtimer_cpu.c b/cpu/native/hwtimer_cpu.c
index 2dc9f1b..4fe0e17 100644
--- a/cpu/native/hwtimer_cpu.c
+++ b/cpu/native/hwtimer_cpu.c
@@ -23,7 +23,8 @@

 #ifdef __MACH__
 #include <mach/clock.h>
-#include <mach/mach.h>
+#include <mach/mach_init.h>
+#include <mach/mach_port.h>
 #endif

 #include <time.h>

@kaspar030
Copy link
Contributor

Fixed for me in master. @thomaseichinger @emmanuelsearch could you confirm and close?

@emmanuelsearch
Copy link
Member Author

builds on master indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Mac OS X Host OS: This PR/issue concerns usage of RIOT with Mac OS X as a host system Platform: native Platform: This PR/issue effects the native platform Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants