From: Ian Lance Taylor Date: Tue, 27 Sep 2016 21:32:50 +0000 (+0000) Subject: libgo: separate mksysinfo inputs into separate Makefile targets X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=14cda8a1cf9ea107eb711aed0f679e56c5d62f26;p=gcc.git libgo: separate mksysinfo inputs into separate Makefile targets This is a step toward a version of mksysinfo that generates information for the runtime package. This will be used to generate the runtime_sysinfo.go file, which is currently directly generated by a Makefile target. Reviewed-on: https://go-review.googlesource.com/29683 From-SVN: r240560 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 1b53f8c1065..8ed62a40b0b 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -8aca265d317059ae6d9721a4a231895d80d0a82c +4046a883070c1f5f58de336f7378f3bca69ea2b6 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/Makefile.am b/libgo/Makefile.am index bd75dd3e02f..81533be09d6 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -691,9 +691,26 @@ s-syscall_arch: Makefile $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ +SYSINFO_FLAGS = \ + $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(OSCFLAGS) -O + +gen-sysinfo.go: s-gen-sysinfo; @true +s-gen-sysinfo: $(srcdir)/sysinfo.c config.h + $(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c + rm -f sysinfo.s + $(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go + $(STAMP) $@ + +errno.i: s-errno; @true +s-errno: + echo '#include ' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i + $(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i + $(STAMP) $@ + sysinfo.go: s-sysinfo; @true -s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS) -O" $(SHELL) $(srcdir)/mksysinfo.sh +s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i + $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ diff --git a/libgo/Makefile.in b/libgo/Makefile.in index 78771c6f258..ebb7ddfc060 100644 --- a/libgo/Makefile.in +++ b/libgo/Makefile.in @@ -946,6 +946,10 @@ extra_go_files_syscall = \ syscall_arch.go \ $(syscall_epoll_file) +SYSINFO_FLAGS = \ + $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(OSCFLAGS) -O + libgo_go_objs = \ bufio.lo \ bytes.lo \ @@ -3638,9 +3642,22 @@ s-syscall_arch: Makefile $(SHELL) $(srcdir)/mvifdiff.sh syscall_arch.go.tmp syscall_arch.go $(STAMP) $@ +gen-sysinfo.go: s-gen-sysinfo; @true +s-gen-sysinfo: $(srcdir)/sysinfo.c config.h + $(CC) $(SYSINFO_FLAGS) -fdump-go-spec=tmp-gen-sysinfo.go -std=gnu99 -S -o sysinfo.s $(srcdir)/sysinfo.c + rm -f sysinfo.s + $(SHELL) $(srcdir)/mvifdiff.sh tmp-gen-sysinfo.go gen-sysinfo.go + $(STAMP) $@ + +errno.i: s-errno; @true +s-errno: + echo '#include ' | $(CC) $(SYSINFO_FLAGS) -x c - -E -dM > tmp-errno.i + $(SHELL) $(srcdir)/mvifdiff.sh tmp-errno.i errno.i + $(STAMP) $@ + sysinfo.go: s-sysinfo; @true -s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS) -O" $(SHELL) $(srcdir)/mksysinfo.sh +s-sysinfo: $(srcdir)/mksysinfo.sh gen-sysinfo.go errno.i + $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index 10e38036c60..eeac94a3ecf 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -4,280 +4,21 @@ # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. -# Create sysinfo.go. +# Create sysinfo.go from gen-sysinfo.go and errno.i. # This shell script creates the sysinfo.go file which holds types and -# constants extracted from the system header files. This relies on a -# hook in gcc: the -fdump-go-spec option will generate debugging -# information in Go syntax. +# constants extracted from the system header files. This reads the +# raw data from gen-sysinfo.go which is generated using the +# -fdump-go-spec option. -# We currently #include all the files at once, which works, but leads -# to exposing some names which ideally should not be exposed, as they -# match grep patterns. E.g., WCHAR_MIN gets exposed because it starts -# with W, like the wait flags. +# This currently exposes some names that ideally should not be +# exposed, as they match grep patterns. E.g., WCHAR_MIN gets exposed +# because it starts with W, like the wait flags. -CC=${CC:-gcc} OUT=tmp-sysinfo.go set -e -rm -f sysinfo.c -cat > sysinfo.c < -#include -#include -#include -#include -#include -/* needs u_char/u_short, but is only - included by if _SGIAPI (i.e. _SGI_SOURCE - && !_XOPEN_SOURCE. - only defines TIOCNOTTY if !_XOPEN_SOURCE, while - does so unconditionally. */ -#ifdef __sgi__ -#include -#include -#endif -#include -#if defined(HAVE_NETINET_IN_SYSTM_H) -#include -#endif -#if defined(HAVE_NETINET_IP_H) -#include -#endif -#if defined(HAVE_NETINET_IP_MROUTE_H) -#include -#endif -#if defined(HAVE_NETINET_IF_ETHER_H) -#include -#endif -#include -#include -#include -#if defined(HAVE_SYSCALL_H) -#include -#endif -#if defined(HAVE_SYS_SYSCALL_H) -#include -#endif -#if defined(HAVE_SYS_EPOLL_H) -#include -#endif -#if defined(HAVE_SYS_FILE_H) -#include -#endif -#if defined(HAVE_SYS_MMAN_H) -#include -#endif -#if defined(HAVE_SYS_PRCTL_H) -#include -#endif -#if defined(HAVE_SYS_PTRACE_H) -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#if defined(HAVE_SYS_USER_H) -#include -#endif -#if defined(HAVE_SYS_UTSNAME_H) -#include -#endif -#if defined(HAVE_SYS_SELECT_H) -#include -#endif -#include -#include -#include -#include -#include -#if defined(HAVE_LINUX_FILTER_H) -#include -#endif -#if defined(HAVE_LINUX_IF_ADDR_H) -#include -#endif -#if defined(HAVE_LINUX_IF_ETHER_H) -#include -#endif -#if defined(HAVE_LINUX_IF_TUN_H) -#include -#endif -#if defined(HAVE_LINUX_NETLINK_H) -#include -#endif -#if defined(HAVE_LINUX_RTNETLINK_H) -#include -#endif -#if defined(HAVE_NET_IF_H) -#include -#endif -#if defined(HAVE_NET_IF_ARP_H) -#include -#endif -#if defined(HAVE_NET_ROUTE_H) -#include -#endif -#if defined (HAVE_NETPACKET_PACKET_H) -#include -#endif -#if defined(HAVE_SYS_MOUNT_H) -#include -#endif -#if defined(HAVE_SYS_VFS_H) -#include -#endif -#if defined(HAVE_STATFS_H) -#include -#endif -#if defined(HAVE_SYS_TIMEX_H) -#include -#endif -#if defined(HAVE_SYS_SYSINFO_H) -#include -#endif -#if defined(HAVE_USTAT_H) -#include -#endif -#if defined(HAVE_UTIME_H) -#include -#endif -#if defined(HAVE_LINUX_ETHER_H) -#include -#endif -#if defined(HAVE_LINUX_FS_H) -#include -#endif -#if defined(HAVE_LINUX_REBOOT_H) -#include -#endif -#if defined(HAVE_SYS_INOTIFY_H) -#include -#endif -#if defined(HAVE_NETINET_ICMP6_H) -#include -#endif -#if defined(HAVE_SCHED_H) -#include -#endif - -/* Constants that may only be defined as expressions on some systems, - expressions too complex for -fdump-go-spec to handle. These are - handled specially below. */ -enum { -#ifdef TIOCGWINSZ - TIOCGWINSZ_val = TIOCGWINSZ, -#endif -#ifdef TIOCSWINSZ - TIOCSWINSZ_val = TIOCSWINSZ, -#endif -#ifdef TIOCNOTTY - TIOCNOTTY_val = TIOCNOTTY, -#endif -#ifdef TIOCSCTTY - TIOCSCTTY_val = TIOCSCTTY, -#endif -#ifdef TIOCGPGRP - TIOCGPGRP_val = TIOCGPGRP, -#endif -#ifdef TIOCSPGRP - TIOCSPGRP_val = TIOCSPGRP, -#endif -#ifdef TIOCGPTN - TIOCGPTN_val = TIOCGPTN, -#endif -#ifdef TIOCSPTLCK - TIOCSPTLCK_val = TIOCSPTLCK, -#endif -#ifdef TIOCGDEV - TIOCGDEV_val = TIOCGDEV, -#endif -#ifdef TIOCSIG - TIOCSIG_val = TIOCSIG, -#endif -#ifdef TCGETS - TCGETS_val = TCGETS, -#endif -#ifdef TCSETS - TCSETS_val = TCSETS, -#endif -#ifdef TUNSETIFF - TUNSETIFF_val = TUNSETIFF, -#endif -#ifdef TUNSETNOCSUM - TUNSETNOCSUM_val = TUNSETNOCSUM, -#endif -#ifdef TUNSETDEBUG - TUNSETDEBUG_val = TUNSETDEBUG, -#endif -#ifdef TUNSETPERSIST - TUNSETPERSIST_val = TUNSETPERSIST, -#endif -#ifdef TUNSETOWNER - TUNSETOWNER_val = TUNSETOWNER, -#endif -#ifdef TUNSETLINK - TUNSETLINK_val = TUNSETLINK, -#endif -#ifdef TUNSETGROUP - TUNSETGROUP_val = TUNSETGROUP, -#endif -#ifdef TUNGETFEATURES - TUNGETFEATURES_val = TUNGETFEATURES, -#endif -#ifdef TUNSETOFFLOAD - TUNSETOFFLOAD_val = TUNSETOFFLOAD, -#endif -#ifdef TUNSETTXFILTER - TUNSETTXFILTER_val = TUNSETTXFILTER, -#endif -#ifdef TUNGETIFF - TUNGETIFF_val = TUNGETIFF, -#endif -#ifdef TUNGETSNDBUF - TUNGETSNDBUF_val = TUNGETSNDBUF, -#endif -#ifdef TUNSETSNDBUF - TUNSETSNDBUF_val = TUNSETSNDBUF, -#endif -#ifdef TUNATTACHFILTER - TUNATTACHFILTER_val = TUNATTACHFILTER, -#endif -#ifdef TUNDETACHFILTER - TUNDETACHFILTER_val = TUNDETACHFILTER, -#endif -#ifdef TUNGETVNETHDRSZ - TUNGETVNETHDRSZ_val = TUNGETVNETHDRSZ, -#endif -#ifdef TUNSETVNETHDRSZ - TUNSETVNETHDRSZ_val = TUNSETVNETHDRSZ, -#endif -#ifdef TUNSETQUEUE - TUNSETQUEUE_val = TUNSETQUEUE, -#endif -#ifdef TUNSETIFINDEX - TUNSETIFINDEX_val = TUNSETIFINDEX, -#endif -#ifdef TUNGETFILTER - TUNGETFILTER_val = TUNGETFILTER, -#endif -#ifdef NLA_HDRLEN - NLA_HDRLEN_val = NLA_HDRLEN, -#endif - -}; -EOF - -${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c - echo 'package syscall' > ${OUT} echo 'import "unsafe"' >> ${OUT} echo 'type _ unsafe.Pointer' >> ${OUT} @@ -302,8 +43,7 @@ grep -v '^// ' gen-sysinfo.go | \ >> ${OUT} # The errno constants. These get type Errno. -echo '#include ' | ${CC} -x c - -E -dM | \ - egrep '#define E[A-Z0-9_]+ ' | \ + egrep '#define E[A-Z0-9_]+ ' errno.i | \ sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT} # The O_xxx flags. diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c new file mode 100644 index 00000000000..07d68673eb0 --- /dev/null +++ b/libgo/sysinfo.c @@ -0,0 +1,259 @@ +/* sysinfo.c -- input for mksysinfo.sh + + Copyright 2009 The Go Authors. All rights reserved. + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. */ + +/* This file is passed to GCC with the -fdump-go-spec option to + generate a Go version of the system information. */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +/* needs u_char/u_short, but is only + included by if _SGIAPI (i.e. _SGI_SOURCE + && !_XOPEN_SOURCE. + only defines TIOCNOTTY if !_XOPEN_SOURCE, while + does so unconditionally. */ +#ifdef __sgi__ +#include +#include +#endif +#include +#if defined(HAVE_NETINET_IN_SYSTM_H) +#include +#endif +#if defined(HAVE_NETINET_IP_H) +#include +#endif +#if defined(HAVE_NETINET_IP_MROUTE_H) +#include +#endif +#if defined(HAVE_NETINET_IF_ETHER_H) +#include +#endif +#include +#include +#include +#if defined(HAVE_SYSCALL_H) +#include +#endif +#if defined(HAVE_SYS_SYSCALL_H) +#include +#endif +#if defined(HAVE_SYS_EPOLL_H) +#include +#endif +#if defined(HAVE_SYS_FILE_H) +#include +#endif +#if defined(HAVE_SYS_MMAN_H) +#include +#endif +#if defined(HAVE_SYS_PRCTL_H) +#include +#endif +#if defined(HAVE_SYS_PTRACE_H) +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(HAVE_SYS_USER_H) +#include +#endif +#if defined(HAVE_SYS_UTSNAME_H) +#include +#endif +#if defined(HAVE_SYS_SELECT_H) +#include +#endif +#include +#include +#include +#include +#include +#if defined(HAVE_LINUX_FILTER_H) +#include +#endif +#if defined(HAVE_LINUX_IF_ADDR_H) +#include +#endif +#if defined(HAVE_LINUX_IF_ETHER_H) +#include +#endif +#if defined(HAVE_LINUX_IF_TUN_H) +#include +#endif +#if defined(HAVE_LINUX_NETLINK_H) +#include +#endif +#if defined(HAVE_LINUX_RTNETLINK_H) +#include +#endif +#if defined(HAVE_NET_IF_H) +#include +#endif +#if defined(HAVE_NET_IF_ARP_H) +#include +#endif +#if defined(HAVE_NET_ROUTE_H) +#include +#endif +#if defined (HAVE_NETPACKET_PACKET_H) +#include +#endif +#if defined(HAVE_SYS_MOUNT_H) +#include +#endif +#if defined(HAVE_SYS_VFS_H) +#include +#endif +#if defined(HAVE_STATFS_H) +#include +#endif +#if defined(HAVE_SYS_TIMEX_H) +#include +#endif +#if defined(HAVE_SYS_SYSINFO_H) +#include +#endif +#if defined(HAVE_USTAT_H) +#include +#endif +#if defined(HAVE_UTIME_H) +#include +#endif +#if defined(HAVE_LINUX_ETHER_H) +#include +#endif +#if defined(HAVE_LINUX_FS_H) +#include +#endif +#if defined(HAVE_LINUX_REBOOT_H) +#include +#endif +#if defined(HAVE_SYS_INOTIFY_H) +#include +#endif +#if defined(HAVE_NETINET_ICMP6_H) +#include +#endif +#if defined(HAVE_SCHED_H) +#include +#endif + +/* Constants that may only be defined as expressions on some systems, + expressions too complex for -fdump-go-spec to handle. These are + handled specially below. */ +enum { +#ifdef TIOCGWINSZ + TIOCGWINSZ_val = TIOCGWINSZ, +#endif +#ifdef TIOCSWINSZ + TIOCSWINSZ_val = TIOCSWINSZ, +#endif +#ifdef TIOCNOTTY + TIOCNOTTY_val = TIOCNOTTY, +#endif +#ifdef TIOCSCTTY + TIOCSCTTY_val = TIOCSCTTY, +#endif +#ifdef TIOCGPGRP + TIOCGPGRP_val = TIOCGPGRP, +#endif +#ifdef TIOCSPGRP + TIOCSPGRP_val = TIOCSPGRP, +#endif +#ifdef TIOCGPTN + TIOCGPTN_val = TIOCGPTN, +#endif +#ifdef TIOCSPTLCK + TIOCSPTLCK_val = TIOCSPTLCK, +#endif +#ifdef TIOCGDEV + TIOCGDEV_val = TIOCGDEV, +#endif +#ifdef TIOCSIG + TIOCSIG_val = TIOCSIG, +#endif +#ifdef TCGETS + TCGETS_val = TCGETS, +#endif +#ifdef TCSETS + TCSETS_val = TCSETS, +#endif +#ifdef TUNSETIFF + TUNSETIFF_val = TUNSETIFF, +#endif +#ifdef TUNSETNOCSUM + TUNSETNOCSUM_val = TUNSETNOCSUM, +#endif +#ifdef TUNSETDEBUG + TUNSETDEBUG_val = TUNSETDEBUG, +#endif +#ifdef TUNSETPERSIST + TUNSETPERSIST_val = TUNSETPERSIST, +#endif +#ifdef TUNSETOWNER + TUNSETOWNER_val = TUNSETOWNER, +#endif +#ifdef TUNSETLINK + TUNSETLINK_val = TUNSETLINK, +#endif +#ifdef TUNSETGROUP + TUNSETGROUP_val = TUNSETGROUP, +#endif +#ifdef TUNGETFEATURES + TUNGETFEATURES_val = TUNGETFEATURES, +#endif +#ifdef TUNSETOFFLOAD + TUNSETOFFLOAD_val = TUNSETOFFLOAD, +#endif +#ifdef TUNSETTXFILTER + TUNSETTXFILTER_val = TUNSETTXFILTER, +#endif +#ifdef TUNGETIFF + TUNGETIFF_val = TUNGETIFF, +#endif +#ifdef TUNGETSNDBUF + TUNGETSNDBUF_val = TUNGETSNDBUF, +#endif +#ifdef TUNSETSNDBUF + TUNSETSNDBUF_val = TUNSETSNDBUF, +#endif +#ifdef TUNATTACHFILTER + TUNATTACHFILTER_val = TUNATTACHFILTER, +#endif +#ifdef TUNDETACHFILTER + TUNDETACHFILTER_val = TUNDETACHFILTER, +#endif +#ifdef TUNGETVNETHDRSZ + TUNGETVNETHDRSZ_val = TUNGETVNETHDRSZ, +#endif +#ifdef TUNSETVNETHDRSZ + TUNSETVNETHDRSZ_val = TUNSETVNETHDRSZ, +#endif +#ifdef TUNSETQUEUE + TUNSETQUEUE_val = TUNSETQUEUE, +#endif +#ifdef TUNSETIFINDEX + TUNSETIFINDEX_val = TUNSETIFINDEX, +#endif +#ifdef TUNGETFILTER + TUNGETFILTER_val = TUNGETFILTER, +#endif +#ifdef NLA_HDRLEN + NLA_HDRLEN_val = NLA_HDRLEN, +#endif +};