Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
7568 Discussions

Help with icc 2021.1, macOS, and cURL

Matt_Thompson
Novice
1,198 Views

All,

First, this is more of an icc than icpc question, but wasn't sure where to post it. Apologies if in wrong forum.

To wit, after seeing that Intel might now be free (maybe?) with oneAPI, I installed it on my MacBook Pro running macOS 10.15, thinking "ooh, a good option for my users". After installation, I tried to compile a set of base libraries for a weather model I help maintain...and ran into an issue. Namely, I can't seem to compile cURL if I use icc instead of clang (using ifort with each, but ifort doesn't matter to cURL). When I try and build cURL with:

$ ./configure --prefix=/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.26/x86_64-apple-darwin19.6.0/ifort/Darwin \
--includedir=/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.26/x86_64-apple-darwin19.6.0/ifort/Darwin/include/ \
--libdir=/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.26/x86_64-apple-darwin19.6.0/ifort/Darwin/lib \
--with-zlib=/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.26/x86_64-apple-darwin19.6.0/ifort/Darwin \
--disable-ldap --enable-manual --disable-shared --enable-static \
--without-libidn --without-libidn2 --without-nghttp2 --without-nghttp3 \
CC=/opt/intel/oneapi/compiler/2021.1.1/mac/bin/intel64/icc \
CXX=/opt/intel/oneapi/compiler/2021.1.1/mac/bin/intel64/icpc \
FC=/opt/intel/oneapi/compiler/2021.1.1/mac/bin/intel64/ifort

the configure step dies with:

checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... no
configure: error: compiler does not halt on function prototype mismatch.
make[1]: *** [GNUmakefile:583: curl.config] Error 1

Staring at the generated code, I see the test C code was:

#     include <stdlib.h>
      int rand(int n);
      int rand(int n)
      {
        if(n)
          return ++n;
        else
          return n;
      }

int main (void)
{
      int i[2]={0,0};
      int j = rand(i[0]);
      if(j)
        return j;
 ;
 return 0;
}

and, yeah, with GCC this does halt (as does clang):

❯ gcc --version
gcc (GCC) 10.2.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

❯ gcc test.c
test.c:2:11: error: conflicting types for ‘rand’
    2 |       int rand(int n);
      |           ^~~~
In file included from test.c:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:162:6: note: previous declaration of ‘rand’ was here
  162 | int  rand(void) __swift_unavailable("Use arc4random instead.");
      |      ^~~~
test.c:3:11: error: conflicting types for ‘rand’
    3 |       int rand(int n)
      |           ^~~~
In file included from test.c:1:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdlib.h:162:6: note: previous declaration of ‘rand’ was here
  162 | int  rand(void) __swift_unavailable("Use arc4random instead.");
      |      ^~~~
❯ echo $?
1

and it doesn't with icc:

❯ icc --version
icc (ICC) 2021.1 Beta 20201112
Copyright (C) 1985-2020 Intel Corporation.  All rights reserved.

❯ icc test.c
test.c(2): warning #147: declaration is incompatible with "int rand(void)" (declared at line 162 of "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/stdlib.h")
        int rand(int n);
            ^

❯ echo $?
0

 So, I thought, I'd try adding -Werror, which will of course halt on it:

❯ icc -Werror test.c
test.c(2): error #147: declaration is incompatible with "int rand(void)" (declared at line 162 of "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/stdlib.h")
        int rand(int n);
            ^

compilation aborted for test.c (code 2)
❯ echo $?
2

but when I add that to the CFLAGS for cURL, it dies again:

checking for gethostbyname... no
checking for gethostbyname in -lnsl... no
checking for gethostbyname in -lsocket... no
checking for gethostbyname in -lwatt... no
checking for gethostbyname with both nsl and socket libs... no
checking for gethostbyname for Minix 3... no
checking for gethostbyname for eCos... no
checking for gethostbyname for AmigaOS bsdsocket.library... no
checking for gethostbyname in -lnetwork... no
checking for gethostbyname in -lnet... no
configure: error: couldn't find libraries for gethostbyname()

So I'm beginning to think I'm out of my element. I've only ever used icc on Linux, so maybe I'm missing something crucial for macOS? 

I know on Linux, I often have to load a gcc module first so that I get "recent" gcc compatibility:

$ icc -v
icc version 19.1.3.304 (gcc version 8.3.0 compatibility)

 and on my Mac I get:

❯ icc -v
icc version 2021.1 (gcc version 4.9.0 compatibility)

I tried pointing PATH to gcc installs on my laptop, but I couldn't seem to get icc to see it. 

Any help from the icc gurus out there?

0 Kudos
1 Solution
Khalik_K_Intel
Moderator
882 Views

Hello,


I reproduced the issue about gethostbyname().

Seems that the problem is in library for libstdc++ not being found (this can be seen in config.log).

Please, try to use -diag-error=147 in addition with -stdlib=libc++.

The second will select libc++ library to be used for linking.


As far as I know libstdc++ has been deprecated some time ago and use of libc++ is recommended.


-stdlib=libc++ solved the issue on my machine and execution succeeded.


Please let me know if this helps.


Regards,

Khalik.


View solution in original post

9 Replies
Gopika_Intel
Moderator
1,183 Views

Hi,

 

Thank you for posting in Intel C++ Compiler forum.

  1. From what we've gathered test.c is throwing a warning because rand() is a library function of stdlib.h, which is used in C/C++ to generate random numbers in the range [0, RAND_MAX) with no input parameters(void). Solution: Either change the name of the user defined function so that it does not conflict with the library function or avoid including stdlib.h.
  2. And about curl build error and getting the latest-gcc-compatibility issue, we're forwarding this case to the internal team who can help you out.

 

Regards

Gopika


Matt_Thompson
Novice
1,168 Views

Gopika,

Well cURL is using this code during it's autotools build to check for capabilities. I guess I was wondering: does icc have a way to "halt on prototype mismatch" other than -Werror?

Of course, it then fails the gethostname bits so...

Viet_H_Intel
Moderator
1,151 Views

When you added -Werror to the build, you forced all warnings to report as an error; which may cause your build to fail. Try -we147 flag instead.


Thanks,


Khalik_K_Intel
Moderator
1,106 Views

Hello,

I was able to reproduce the original problem "Compiler halt on a prototype mismatch" on the machine with oneAPI installed:

checking if compiler halts on compilation errors... yes
checking if compiler halts on negative sized arrays... yes
checking if compiler halts on function prototype mismatch... no
configure: error: compiler does not halt on function prototype mismatch.
$ icc -v
icc version 2021.1 (gcc version 4.9.0 compatibility)
$ sw_vers
ProductName:    macOS
ProductVersion: 11.1

However, the addition of -Werror flag did not make cURL to crash - execution finished successfully.
So, I will do more investigation on this.

In addition to what Viet suggested, I can recommend to use -diag-error=147 as it is a replacement to -we option, which is marked as deprecated.

Regarding the gcc version, you could try to use -gcc-name option and specify gcc compiler that should be used to set up the environment for C compilations.

Regards,

Khalik.

Matt_Thompson
Novice
1,059 Views

Okay. If I pass in `-diag-error=147` it does get past the first error, but I still die later:

 

checking whether to use libgcc... no
checking if X/Open network library is required... no
checking for gethostbyname... no
checking for gethostbyname in -lnsl... no
checking for gethostbyname in -lsocket... no
checking for gethostbyname in -lwatt... no
checking for gethostbyname with both nsl and socket libs... no
checking for gethostbyname for Minix 3... no
checking for gethostbyname for eCos... no
checking for gethostbyname for AmigaOS bsdsocket.library... no
checking for gethostbyname in -lnetwork... no
checking for gethostbyname in -lnet... no
configure: error: couldn't find libraries for gethostbyname()
make[1]: *** [GNUmakefile:583: curl.config] Error 1
make[1]: Leaving directory '/Users/mathomp4/Baselibs/ESMA-Baselibs-6.0.26/src'
make: *** [GNUmakefile:356: install] Error 2

 

Not sure why. Maybe a macOS issue? It doesn't happen with clang.

Note that I can't use `-gcc-name` with macOS because it's not supported:

 

Matt_Thompson
Novice
1,056 Views

Looks like the last part got cut-off:

❯ icc -gcc-name=/usr/bin/clang -v
icc: command line warning #10006: ignoring unknown option '-gcc-name=/usr/bin/clang'
icc version 2021.1 (gcc version 4.9.0 compatibility)
Khalik_K_Intel
Moderator
883 Views

Hello,


I reproduced the issue about gethostbyname().

Seems that the problem is in library for libstdc++ not being found (this can be seen in config.log).

Please, try to use -diag-error=147 in addition with -stdlib=libc++.

The second will select libc++ library to be used for linking.


As far as I know libstdc++ has been deprecated some time ago and use of libc++ is recommended.


-stdlib=libc++ solved the issue on my machine and execution succeeded.


Please let me know if this helps.


Regards,

Khalik.


View solution in original post

Matt_Thompson
Novice
861 Views

@Khalik_K_Intel I think you got it! I can build all my libraries now it looks like. I installed them in the wrong place so I have build them all again, but I can build them! Thanks!

Khalik_K_Intel
Moderator
845 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread.

Any further interaction in this thread will be considered community only.


Reply