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

Conflict with unistd.h on Mac OS #1046

Closed
DavisVaughan opened this issue Mar 15, 2020 · 11 comments · Fixed by #1047
Closed

Conflict with unistd.h on Mac OS #1046

DavisVaughan opened this issue Mar 15, 2020 · 11 comments · Fixed by #1047

Comments

@DavisVaughan
Copy link
Contributor

CC @kevinushey who has also been helping me with this

Minimum package to reproduce issue:
https://github.com/DavisVaughan/testunistd

If I am on the dev version of Rcpp, 1.0.4, then I cannot compile the package linked above. It includes this header declaration ordering:

// Works on 1.0.3
// Fails on github 1.0.4
#include <Rcpp.h>
#include <unistd.h>
  • If I use 1.0.3, it works as is
  • If I reverse the include ordering while on 1.0.4, it works

I am on Mac OS 10.14.5

This is the error that I get, it looks like some conflict with the sys/_types/_uuid_t.h file in the mac SDK, but I haven't been able to track it down any further than this.

> devtools::load_all(".")
Loading testunistd
Re-compiling testunistd
─  installing *source* package ‘testunistd’ ...
   ** using staged installation
   ** libs
   clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -Wall -g -O2  -c code.cpp -o code.o
   In file included from code.cpp:4:
   In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:658:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/gethostuuid.h:39:17: error: C++ requires a type specifier for all declarations
   int gethostuuid(uuid_t, const struct timespec *) __OSX_AVAILABLE_STARTING(__MAC_10_5, __IPHONE_NA);
                   ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:665:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      getsgroups_np(int *, uuid_t);
                                 ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:667:27: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      getwgroups_np(int *, uuid_t);
                                 ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:730:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      setsgroups_np(int, const uuid_t);
                                     ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   In file included from code.cpp:4:
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:732:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
   int      setwgroups_np(int, const uuid_t);
                                     ^
   /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
   typedef __darwin_uid_t        uid_t;
                                 ^
   5 errors generated.
   make: *** [code.o] Error 1
   ERROR: compilation failed for package ‘testunistd’
─  removing ‘/private/var/folders/41/qx_9ygp112nfysdfgxcssgwc0000gn/T/Rtmp62mMQq/devtools_install_11e537e56fd61/testunistd’
Error in (function (command = NULL, args = character(), error_on_status = TRUE,  : 
  System command 'R' failed, exit status: 1, stdout + stderr (last 10 lines):
E> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h:732:31: error: unknown type name 'uuid_t'; did you mean 'uid_t'?
E> int      setwgroups_np(int, const uuid_t);
E>                                   ^
E> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/_types/_uid_t.h:31:31: note: 'uid_t' declared here
E> typedef __darwin_uid_t        uid_t;
E>                               ^
E> 5 errors generated.
E> make: *** [code.o] Error 1
E> ERROR: compilation failed for package ‘testunistd’
E> * removing ‘/private/var/folders/41/qx_9ygp112nfysdfgxcssgwc0000gn/T/Rtmp62mMQq/devtools_install_11e537e56fd61/testunistd’
Type .Last.error.trace to see where the error occured
@eddelbuettel
Copy link
Member

🤷‍♂️

That looks like it is between you and macOS. If reordering helps, I suggest you reorder.

@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented Mar 15, 2020

It prevents me from compiling vroom, which used to compile fine. I'm wondering if there are other packages out there that will get hit with this (vroom also links to the progress package, which also seems to have this issue)

I'm just curious, can you reproduce since you don't use a Mac?

@eddelbuettel
Copy link
Member

So change the ordering in vroom too. Not one line in what you showed has anything to do with Rcpp.

I did not claim to have reproduced it so I am not sure where your second paragraph is coming from.

@eddelbuettel
Copy link
Member

For what it is worth, I ran 1800+ reverse depends checks a number of times before submitting Rcpp to CRAN. Nothing came up so far, and that includes checking with vroom. And the above is not quite yet a MCVE so there is strictly nothing I can do.

You, on the other, have something reproducible. Maybe you can trace what, if anything, defines something somwhere so that it interacts with the system header on your box. If you can't, you can't but I would seem that nobody else can either (unless they have access to a similar macOS box which I do not).

@DavisVaughan
Copy link
Contributor Author

I think it may be something in this commit. It compiles before this one. Still trying to track it down further
2815ae8

@eddelbuettel
Copy link
Member

Good move. Should have thought about bi-section. Appreciate that you are trying something.

@eddelbuettel eddelbuettel reopened this Mar 15, 2020
@DavisVaughan
Copy link
Contributor Author

Should <execinfo.h> be used on MacOS? This section of code seems to be carefully avoided except on Mac and Linux, I am wondering if it needs to be avoided on Mac too.

2815ae8#diff-4cc51a3796e8e592821e21d4ed9a6c03R3-R6

There are reports here that it is Linux only
shedskin/shedskin#240

Even though the reports state that it is Linux only, I do see the file on my computer at this location, and that seems to be what is being used:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/execinfo.h

Just as a rough test, I commented out the include of <execinfo.h> along with the usage of backtrace() and backtrace_symbols() that come from that commit. I was then able to compile with no issues.

It may be as simple as also avoiding this feature on apple products by adding defined(__APPLE__) to this line 2815ae8#diff-4cc51a3796e8e592821e21d4ed9a6c03R3, which is also what was done here:
shedskin/shedskin@1e88884#diff-8b68c579a8fce0e847ad29adab20771eR32

@kevinushey
Copy link
Contributor

I can reproduce as well. It looks like the inclusion of <execinfo.h> is most likely the culprit -- some sort of awkward issue related to include order?

Explicitly including <unistd.h> before <execinfo.h> fixes the issue. This is surprising to me though and sort of feels like a bug in the macOS toolchain.

@eddelbuettel
Copy link
Member

eddelbuettel commented Mar 15, 2020

We could also offer a #define Rcpp_No_Exception_Demangler or something and expand the already long list of [indented by me here]

    #if defined(_WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) 
              || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) 
              || defined(_AIX) || defined(__MUSL__) || defined(__HAIKU__) 
              || defined(__ANDROID__)

to not try to include execinfo.h. Just a thought.

@kevinushey
Copy link
Contributor

I just realized the problem. We're including <execinfo.h> inside the Rcpp namespace, rather than globally.

#include <execinfo.h>

I think we were doing exactly this before (and somehow got away with it), but include orders in Rcpp must've changed to expose us to this bug.

@kevinushey
Copy link
Contributor

I'll make a PR to fix this up.

tnagler pushed a commit to vinecopulib/rvinecopulib that referenced this issue Mar 30, 2020
tvatter pushed a commit to vinecopulib/rvinecopulib that referenced this issue May 5, 2020
* switch to github actions

* what happened

* no idea

* do one check on R 3.5

* remove CRAN mirror on actions/linux

* try different shell for escaping issue

* escape one more?

* change CI badge

* Rcpp bug on macOS-3.5 RcppCore/Rcpp#1046

* same bug on macOS-3.6

* trigger

* use R 4.0
tnagler added a commit to vinecopulib/rvinecopulib that referenced this issue May 7, 2020
* Better structures (#203)

* allow single integer construction of C/D-vines

* a few unit tests

* export plot.rvine_matrix

* unit tests for plot functions

* add `var_names = "hide"` option in plot.vinecop_dist()

* pass dots to plot.vinecop_dist()

* fix plot.vinecop_dist() docs

* fix tau->par for frank (#207)

* fix tau->par for frank

* update version and NEWS

* some typos and doc formatting (#208)

* switch to github actions (#204)

* switch to github actions

* what happened

* no idea

* do one check on R 3.5

* remove CRAN mirror on actions/linux

* try different shell for escaping issue

* escape one more?

* change CI badge

* Rcpp bug on macOS-3.5 RcppCore/Rcpp#1046

* same bug on macOS-3.6

* trigger

* use R 4.0

* pull current dev (#209)

* Prepare release (#210)

* bump version

* update NEWS

* cran comments

* update website
tvatter pushed a commit to vinecopulib/rvinecopulib that referenced this issue Aug 10, 2020
* Better structures (#203)

* allow single integer construction of C/D-vines

* a few unit tests

* export plot.rvine_matrix

* unit tests for plot functions

* add `var_names = "hide"` option in plot.vinecop_dist()

* pass dots to plot.vinecop_dist()

* fix plot.vinecop_dist() docs

* fix tau->par for frank (#207)

* fix tau->par for frank

* update version and NEWS

* some typos and doc formatting (#208)

* switch to github actions (#204)

* switch to github actions

* what happened

* no idea

* do one check on R 3.5

* remove CRAN mirror on actions/linux

* try different shell for escaping issue

* escape one more?

* change CI badge

* Rcpp bug on macOS-3.5 RcppCore/Rcpp#1046

* same bug on macOS-3.6

* trigger

* use R 4.0

* pull current dev (#209)

* allow 1-dimensional models

* select

* matrix -> RvineStructure

* more infrastructure + unit tests

* more unit tests

* CRAN checks
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 a pull request may close this issue.

3 participants