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

Fix #12138 - use cc on OpenBSD and link libm #14672

Merged
merged 1 commit into from
Jun 16, 2020

Conversation

euantorano
Copy link
Contributor

Fixes #12138.

This patch uses cc rather than gcc on openBSD (the GCC shipped is an old version - gcc version 4.2.1 20070719 as of OpenBSD 6.7; cc is clang OpenBSD clang version 8.0.1 (tags/RELEASE_801/final) (based on LLVM 8.0.1)).

It also links libm as mentioned in #12138 (comment).

The detect tool now builds and runs successfully on OpenBSD:

bin/nim c -r tools/detect/detect.nim
Hint: used config file '/home/euan/src/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/euan/src/Nim/config/config.nims' [Conf]
..................
/home/euan/src/Nim/tools/detect/detect.nim(46, 3) Hint: 'ifile' is declared but not used [XDeclaredButNotUsed]
/home/euan/src/Nim/tools/detect/detect.nim(20, 5) Hint: 'cpp' is declared but not used [XDeclaredButNotUsed]
Hint: clang -c  -w   -I/home/euan/src/Nim/lib -I/home/euan/src/Nim/tools/detect -o /home/euan/.cache/nim/detect_d/@mdetect.nim.c.o /home/euan/.cache/nim/detect_d/@mdetect.nim.c [Exec]
Hint:  [Link]
Hint: 61035 lines; 37.213s; 98.68MiB peakmem; Debug build; proj: /home/euan/src/Nim/tools/detect/detect.nim; out: /home/euan/src/Nim/tools/detect/detect [SuccessX]
Hint: /home/euan/src/Nim/tools/detect/detect  [Exec]
CMD cc -o testh testh.c
testh.c:1:10: fatal error: 'aio.h' file not found
#include <aio.h>
         ^~~~~~~
1 error generated.
Not found: <aio.h>
CMD cc -o testh testh.c
Found: <dlfcn.h>
CMD cc -o testh testh.c
Found: <errno.h>
CMD cc -o testh testh.c
Found: <fcntl.h>
CMD cc -o testh testh.c
Found: <fenv.h>
CMD cc -o testh testh.c
testh.c:1:10: fatal error: 'fmtmsg.h' file not found
#include <fmtmsg.h>
         ^~~~~~~~~~
1 error generated.
Not found: <fmtmsg.h>
CMD cc -o testh testh.c
Found: <fnmatch.h>
CMD cc -o testh testh.c
Found: <ftw.h>
CMD cc -o testh testh.c
Found: <glob.h>
CMD cc -o testh testh.c
Found: <langinfo.h>
CMD cc -o testh testh.c
Found: <locale.h>
CMD cc -o testh testh.c
Found: <netdb.h>
CMD cc -o testh testh.c
Found: <net/if.h>
CMD cc -o testh testh.c
Found: <netinet/in.h>
CMD cc -o testh testh.c
In file included from testh.c:1:
/usr/include/netinet/tcp.h:42:9: error: unknown type name 'u_int32_t'; did you mean '__int128_t'?
typedef u_int32_t tcp_seq;
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:49:2: error: unknown type name 'u_int16_t'; did you mean '__int128_t'?
        u_int16_t th_sport;             /* source port */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:50:2: error: unknown type name 'u_int16_t'; did you mean '__int128_t'?
        u_int16_t th_dport;             /* destination port */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:54:2: error: unknown type name 'u_int32_t'; did you mean '__int128_t'?
        u_int32_t th_x2:4,              /* (unused) */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:58:2: error: unknown type name 'u_int32_t'; did you mean '__int128_t'?
        u_int32_t th_off:4,             /* data offset */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:58:12: error: duplicate member 'th_off'
        u_int32_t th_off:4,             /* data offset */
                  ^
/usr/include/netinet/tcp.h:55:5: note: previous declaration is here
                  th_off:4;             /* data offset */
                  ^
/usr/include/netinet/tcp.h:59:5: error: duplicate member 'th_x2'
                  th_x2:4;              /* (unused) */
                  ^
/usr/include/netinet/tcp.h:54:12: note: previous declaration is here
        u_int32_t th_x2:4,              /* (unused) */
                  ^
/usr/include/netinet/tcp.h:61:2: error: unknown type name 'u_int8_t'
        u_int8_t  th_flags;
        ^
/usr/include/netinet/tcp.h:70:2: error: unknown type name 'u_int16_t'; did you mean '__int128_t'?
        u_int16_t th_win;                       /* window */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:71:2: error: unknown type name 'u_int16_t'; did you mean '__int128_t'?
        u_int16_t th_sum;                       /* checksum */
        ^
note: '__int128_t' declared here
/usr/include/netinet/tcp.h:72:2: error: unknown type name 'u_int16_t'; did you mean '__int128_t'?
        u_int16_t th_urp;                       /* urgent pointer */
        ^
note: '__int128_t' declared here
11 errors generated.
Not found: <netinet/tcp.h>
CMD cc -o testh testh.c
Found: <nl_types.h>
CMD cc -o testh testh.c
Found: <poll.h>
CMD cc -o testh testh.c
Found: <pthread.h>
CMD cc -o testh testh.c
Found: <sched.h>
CMD cc -o testh testh.c
Found: <semaphore.h>
CMD cc -o testh testh.c
Found: <signal.h>
CMD cc -o testh testh.c
Found: <sys/ipc.h>
CMD cc -o testh testh.c
Found: <sys/mman.h>
CMD cc -o testh testh.c
Found: <sys/resource.h>
CMD cc -o testh testh.c
Found: <sys/select.h>
CMD cc -o testh testh.c
Found: <sys/socket.h>
CMD cc -o testh testh.c
Found: <sys/stat.h>
CMD cc -o testh testh.c
Found: <sys/statvfs.h>
CMD cc -o testh testh.c
Found: <sys/wait.h>
CMD cc -o testh testh.c
Found: <spawn.h>
CMD cc -o testh testh.c
Found: <stdio.h>
CMD cc -o testh testh.c
Found: <time.h>
CMD cc -o testh testh.c
Found: <unistd.h>
CMD cc -lm -o genconsts genconsts.c
genconsts.c:444:48: warning: format specifies type 'int' but the argument has type 'const fenv_t *' [-Wformat]
  fprintf(f, "const FE_DFL_ENV* = cint(%d)\n", FE_DFL_ENV);
                                       ~~      ^~~~~~~~~~
/usr/include/machine/fenv.h:99:21: note: expanded from macro 'FE_DFL_ENV'
#define FE_DFL_ENV              ((const fenv_t *)&__fe_dfl_env)
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
genconsts.c:1121:57: warning: format specifies type 'int' but the argument has type 'void (*)(int)' [-Wformat]
  fprintf(f, "const SIG_DFL* = cast[Sighandler](%d)\n", SIG_DFL);
                                                ~~      ^~~~~~~
/usr/include/sys/signal.h:97:18: note: expanded from macro 'SIG_DFL'
#define SIG_DFL         (void (*)(int))0
                        ^~~~~~~~~~~~~~~~
genconsts.c:1124:57: warning: format specifies type 'int' but the argument has type 'void (*)(int)' [-Wformat]
  fprintf(f, "const SIG_ERR* = cast[Sighandler](%d)\n", SIG_ERR);
                                                ~~      ^~~~~~~
/usr/include/sys/signal.h:99:18: note: expanded from macro 'SIG_ERR'
#define SIG_ERR         (void (*)(int))-1
                        ^~~~~~~~~~~~~~~~~
genconsts.c:1127:57: warning: format specifies type 'int' but the argument has type 'void (*)(int)' [-Wformat]
  fprintf(f, "const SIG_IGN* = cast[Sighandler](%d)\n", SIG_IGN);
                                                ~~      ^~~~~~~
/usr/include/sys/signal.h:98:18: note: expanded from macro 'SIG_IGN'
#define SIG_IGN         (void (*)(int))1
                        ^~~~~~~~~~~~~~~~
genconsts.c:1140:49: warning: format specifies type 'int' but the argument has type 'key_t' (aka 'long') [-Wformat]
  fprintf(f, "const IPC_PRIVATE* = cint(%d)\n", IPC_PRIVATE);
                                        ~~      ^~~~~~~~~~~
                                        %ld
/usr/include/sys/ipc.h:73:21: note: expanded from macro 'IPC_PRIVATE'
#define IPC_PRIVATE     (key_t)0 /* private key */
                        ^~~~~~~~
genconsts.c:1428:47: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  fprintf(f, "const ST_RDONLY* = cint(%d)\n", ST_RDONLY);
                                      ~~      ^~~~~~~~~
                                      %lu
/usr/include/sys/statvfs.h:38:19: note: expanded from macro 'ST_RDONLY'
#define ST_RDONLY       0x0001UL        /* read-only filesystem */
                        ^~~~~~~~
genconsts.c:1431:47: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  fprintf(f, "const ST_NOSUID* = cint(%d)\n", ST_NOSUID);
                                      ~~      ^~~~~~~~~
                                      %lu
/usr/include/sys/statvfs.h:39:19: note: expanded from macro 'ST_NOSUID'
#define ST_NOSUID       0x0002UL        /* nosuid flag set */
                        ^~~~~~~~
genconsts.c:1492:54: warning: format specifies type 'long' but the argument has type 'int' [-Wformat]
  fprintf(f, "const CLOCKS_PER_SEC* = clong(%ld)\n", CLOCKS_PER_SEC);
                                            ~~~      ^~~~~~~~~~~~~~
                                            %d
/usr/include/time.h:71:24: note: expanded from macro 'CLOCKS_PER_SEC'
#define CLOCKS_PER_SEC  100     /* frequency of ticks reported by clock().  */
                        ^~~
8 warnings generated.
CMD cc -lm -E -o pre.i pre.c
cc: warning: -lm: 'linker' input unused [-Wunused-command-line-argument]
CMD ./genconsts
Success

@Araq Araq merged commit 7b12f13 into nim-lang:devel Jun 16, 2020
@euantorano euantorano deleted the fix/12138-detect-openbsd branch June 16, 2020 07:35
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 this pull request may close these issues.

Detect tool fails on OpenBSD: undefined symbol: __fe_dfl_env
2 participants