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

compilation error on AIX #1351

Closed
vinhdizzo opened this issue Sep 21, 2015 · 18 comments
Closed

compilation error on AIX #1351

vinhdizzo opened this issue Sep 21, 2015 · 18 comments

Comments

@vinhdizzo
Copy link

Hi,

Trying to install data.table on R 3.2.2 on AIX, and am getting the following error. Any suggestions would be greatly appreciated.

> install.packages("data.table", repo = "http://cran.stat.ucla.edu")
trying URL 'http://cran.stat.ucla.edu/src/contrib/data.table_1.9.4.tar.gz'
Content type 'application/x-tar' length 949746 bytes (927 KB)
==================================================
downloaded 927 KB

* installing *source* package 'data.table' ...
** package 'data.table' successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/sas/outmva/opt/lib/R/include -DNDEBUG  -I/usr/local/include  -mno-fp-in-toc    -g -O2  -c assign.c -o assign.o
gcc -std=gnu99 -I/sas/outmva/opt/lib/R/include -DNDEBUG  -I/usr/local/include  -mno-fp-in-toc    -g -O2  -c bmerge.c -o bmerge.o
bmerge.c:25:17: error: 'nearest' redeclared as different kind of symbol
 static Rboolean nearest=FALSE, enc_warn=TRUE;
                 ^
In file included from /sas/outmva/opt/lib/R/include/R.h:31:0,
                 from data.table.h:1,
                 from bmerge.c:1:
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.8.3/include-fixed/math.h:1383:21: note: previous declaration of 'nearest' was here
 extern     double   nearest(double);
                     ^
bmerge.c:109:21: error: 'class' redeclared as different kind of symbol
 static SEXP ic, xc, class;
                     ^
In file included from /sas/outmva/opt/lib/R/include/R.h:31:0,
                 from data.table.h:1,
                 from bmerge.c:1:
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.8.3/include-fixed/math.h:1398:21: note: previous declaration of 'class' was here
 extern     int      class();
                     ^
/sas/outmva/opt/lib/R/etc/Makeconf:134: recipe for target 'bmerge.o' failed
make: *** [bmerge.o] Error 1
ERROR: compilation failed for package 'data.table'
* removing '/sas/outmva/opt/lib/R/library/data.table'

The downloaded source packages are in
        '/tmp/Rtmpf3o7ma/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("data.table", repo = "http://cran.stat.ucla.edu") :
  installation of package 'data.table' had non-zero exit status
@mattdowle
Copy link
Member

I see you're PowerPC. Please try again with v1.9.6 which has just been released to CRAN this weekend. It passed PowerPC under QEMU emulation. Having said that, I haven't seen these errors about class() or nearest() before so I suspect v1.9.6 will not fix it. A google search for "IBM AIX previous declaration of 'nearest'" throws up other packages having similar issues. If you could investigate those threads and let us know what we need to do that'd be great if possible. (We have no IBM AIX machine to test.)

@vinhdizzo
Copy link
Author

Thanks for the prompt response Matt.

Tried 1.9.6 and the errors persist. Googled the "IBM AIX previous declaration", and both this and this points to the ordering of the include statement. Don't know what the proper ordering should be...maybe it's more apparent to you. Thanks.

@mattdowle
Copy link
Member

Thanks - useful. Had a quick look but can't see what to change. The symbol nearest occurs in bmerge.c only and is declared as a static Rboolean, so I don't see how this could conflict with math.h.
You're using "-std=gnu99" so why would math.h on your platform contain extern nearest when it doesn't on other platforms. Doesn't GNU99 say what is and isn't in the .h files?
CRAN tests on several flavours of Linux, Solaris, Windows and Mac (https://cran.r-project.org/web/checks/check_results_data.table.html) and it passes there (other than Solaris Sparc which is a different problem I believe).
If you could raise this on an AIX support list somewhere for us please and find someone who might know, that would be great. Thanks.

@vinhdizzo
Copy link
Author

Sorry, this is going beyond my comfort zone (not really familiar with this).

Both threads mention "before the system header files" in their fixes. Is there a way to include 'R.h' before 'math.h'?

@mattdowle
Copy link
Member

The string 'math.h' doesn't occur anywhere in data.table source so I don't see how.
Don't you have any AIX support channels open to you?

@mattdowle
Copy link
Member

I suppose we could change the C symbol names from 'nearest' and 'class' to something else.
But such an effort/guess grates. You paid for IBM hardware and support so they should be helping, or at least responding.

@vinhdizzo
Copy link
Author

Hey Matt,

The decision to have this AIX box was made years ago before I arrived here in my current employment, and there really isn't much support from our IT because they themselves aren't that familiar with UNIX/Linux. In terms of support from IBM, I'm not even going to attempt it because it would involve too much red tape, requiring approvals and worst yet, may require $. Not much of an appetite around here just to satisfy my requirements for getting things to work in R.

I don't even think IBM would be much help here because I'm not even using the compilers provided by them (again, too much hassle). I was able to get get the GNU compilers to work on AIX thanks Michael Perlz who maintains this wonderful site. I preferred to use the GNU compilers because at least the same compilers are used in other distros, hence better support from others.

I'll reach out to that maintainer to see if he's seen this error before in his experience dealing with AIX. If he doesn't have a clue, then I really think my luck stops there. I would then very much appreciate you changing those symbol names. Thanks again.

@mattdowle
Copy link
Member

Thanks for the further info and background. Understood. I've changed the symbol names. To try it, please :

git clone https://github.com/Rdatatable/data.table.git
or
wget https://github.com/Rdatatable/data.table/archive/master.zip
then
R CMD build --no-build-vignettes data.table
R CMD check data.table_1.9.7.tar.gz
R CMD INSTALL data.table_1.9.7.tar.gz
R
test.data.table()

@vinhdizzo
Copy link
Author

Thank you so much Matt for the fix. It installs on AIX now.

If I do hear back from Michael Perlz (maintainter of many compiled packages for AIX), I'll post here so you know as well. Thanks again.

@vinhdizzo
Copy link
Author

I was just trying to install a different package (geosphere) and ran into some issues with TRUE or FALSE. Did a search on it and found this thread, and undef'ing TRUE and FALSE made the packages compiled. I just tried "#undef class" and "#undef nearest" on top of bmerge.c in the previous data.table version, but no go. However, I don't think "#undef" is valid for these. Is there a proper way to do this? If so, I could try it out. Thanks!

@mattdowle
Copy link
Member

Thanks for the confirm. Glad resolved.
I had a look at that thread about new issue TRUE/FALSE on a different package (geosphere), but sorry I don't know. If those are gcc headers then perhaps speak to those folk and maybe create a patch or a local copy of the headers without those defines.

mattdowle added a commit that referenced this issue Sep 22, 2015
@vinhdizzo
Copy link
Author

Regarding that geosphere, I just manually modified the source (undef'ing) and compiled successfully.

I was just curious as to whether I could manually "#undef nearest" and "#undef class" (or something similar) at the beginning of bmerge.c to see if it works. If it did, then in the future when I run into this AIX issue I would manually modify the source myself without having to bother the package maintainer as this clearly is an AIX problem.

Was just getting your thoughts if there was an analogous way to 'undef' the 'class' and 'nearest' in your package, that's all.

Thanks again.

@mattdowle
Copy link
Member

That doesn't seem right to me. If those are gcc headers then perhaps speak to those folk and maybe create a patch or a local copy of the headers without those defines. i.e. find the .h in your system and simply remove the offending #define's, taking a backup first of course. Then you don't need to do anything for each package.

@vinhdizzo
Copy link
Author

Hey Matt,

I mentioned this issue on the gcc-help mailing list and was given this response. Does it make sense? Just an FYI. Thanks again!

@aixtools
Copy link

re: the comments from gcc-help - I also package a gcc compiler for AIX (and have a test version with fortran in it I am using to test R for AIX).

The issue with "class" is many many lines on AIX, however, the name "nearest" is easiest to display:
root@x072:[/data/prj/cran/modules]grep nearest /usr/include/*
/usr/include/decContext.h: DEC_ROUND_HALF_EVEN, /* 0.5 rounds to nearest even /
/usr/include/float.h: * RN = Round toward nearest (default)
/usr/include/math.h:extern double nearest();
/usr/include/math.h:extern double nearest(double);
/usr/include/math.h:/
This is the nearest number to the cube root of MAXDOUBLE that */
root@x072:[/data/prj/cran/modules]

"nearest()" seems to be claimed by IEEE math functions - so I am surprised that gcc would not be having namespace collision as well.

re: class - I would expect that to be a reserved in many languages, so I am not too surprised.

For brevity, I am not including the grep with class as "string to find".

I shall apply the patch, and I hope you soon update data.table_1.9.6.tar

Michael aka aixtools

@aixtools
Copy link

p.s. as I am very new to R - trying this for a friend, I do not understand who to use either the clone git instructions, or the master.zip file (with, although similar, is much smaller than the 1.9.6.tar file I am trying to install).

The instructions I had received were merely - get the file, ungzip it and then, in R
install.packages("./data.table_1.9.6.tar",repos=NULL,type="source")

My apologies for being so "simple-minded".

@jangorecki
Copy link
Member

@aixtools You can install 1.9.6 from source directly from CRAN by

install.packages("data.table", type="source")

If you need currently latest 1.9.7 (I've just refreshed the snapshot of master) you can use this:

install.packages("data.table", repos="https://jangorecki.github.io/data.table", type="source")

@aixtools
Copy link

Thanks.
my friend I am helping prepped a tar file for, and it packaged without an issue.
On to Rcpp ...

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

No branches or pull requests

4 participants