[Bug go/105225] New: build failure with musl libc 1.2.3 due to sysinfo.go error: redefinition of 'SYS_SECCOMP'

2022-04-11 Thread ncopa at alpinelinux dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105225

Bug ID: 105225
   Summary: build failure with musl libc 1.2.3 due to sysinfo.go
error: redefinition of 'SYS_SECCOMP'
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: go
  Assignee: ian at airs dot com
  Reporter: ncopa at alpinelinux dot org
CC: cmang at google dot com
  Target Milestone: ---

Building gcc 11.2.1 with musl libc 1.2.3 fails with:

11.2.1_git20220219/libgo/go/syscall/time_nofake.go
/home/ncopa/aports/main/gcc/src/gcc-11.2.1_git20220219/libgo/go/syscall/timestruct.go
libcalls.go sysinfo.go syscall_arch.go syscall_linknames.go epoll.go  -fPIC -o
.libs/syscall.o
sysinfo.go:6606:7: error: redefinition of 'SYS_SECCOMP'
 6606 | const SYS_SECCOMP = _SYS_SECCOMP
  |   ^
sysinfo.go:6600:7: note: previous definition of 'SYS_SECCOMP' was here
 6600 | const SYS_SECCOMP = _SYS_seccomp
  |   ^
make[2]: *** [Makefile:3001: syscall.lo] Error 1

The generation of sysinfo.go will try extract syscalls and convert them to
uppercase. It gets duplicated by the uppercase SYS_SECCOMP introduced in with
musl commit:
https://git.musl-libc.org/cgit/musl/commit/?id=3dcbd896907d9d474da811b7c6b769342abaf651

A possible fix is to only grep for syscalls with lowercase letters:
diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh
index 6fef104..06289a4 100755
--- a/libgo/mksysinfo.sh
+++ b/libgo/mksysinfo.sh
@@ -126,7 +126,7 @@ if ! grep '^const SIGCLD ' ${OUT} >/dev/null 2>&1; then
 fi

 # The syscall numbers.  We force the names to upper case.
-grep '^const _SYS_' gen-sysinfo.go | \
+grep '^const _SYS_[a-z]' gen-sysinfo.go | \
   sed -e 's/const _\(SYS_[^= ]*\).*$/\1/' | \
   while read sys; do
 sup=`echo $sys | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`

[Bug ipa/96734] gcc 10.2.0 fails to compile on mips64 due to crash in IPA SRA pass

2020-11-13 Thread ncopa at alpinelinux dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96734

Natanael Copa  changed:

   What|Removed |Added

 CC||ncopa at alpinelinux dot org

--- Comment #7 from Natanael Copa  ---
I was able to reproduce using latest commit from gcc 10 branch:

/home/ncopa/aports/main/gcc/src/build/./prev-gcc/xg++
-B/home/ncopa/aports/main/gcc/src/build/./prev-gcc/
-B/usr/mips64-alpine-linux-musl/bin/ -nostdinc++
-B/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/src/.libs
-B/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/libsupc++/.libs

-I/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/include/mips64-alpine-linux-musl

-I/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/include
 -I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/libstdc++-v3/libsupc++
-L/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/src/.libs
-L/home/ncopa/aports/main/gcc/src/build/prev-mips64-alpine-linux-musl/libstdc++-v3/libsupc++/.libs
-fno-PIE -c  -DIN_GCC_FRONTEND -g -O2 -fno-checking -gtoggle  -DIN_GCC
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing
-Wwrite-strings -Wcast-qual -Wno-error=format-diag -Wmissing-format-attribute
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros
-Wno-overlength-strings   -DHAVE_CONFIG_H -I. -Icp
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cp
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/../include
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/../libcpp/include 
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/../libdecnumber
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/../libdecnumber/dpd
-I../libdecnumber
-I/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/../libbacktrace  -Os
-fomit-frame-pointer -o cp/method.o -MT cp/method.o -MMD -MP -MF
cp/.deps/method.TPo /home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cp/method.c
during IPA pass: sra
In file included from
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cp/method.c:3199:
./gt-cp-method.h:36:2: internal compiler error: Segmentation fault
   36 | };
  |  ^
0x120807513 crash_signal
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/toplev.c:328
0x1204210f5 cgraph_edge::redirect_callee(cgraph_node*)
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cgraph.c:1374
0x1204340c3 cgraph_edge::redirect_callee_duplicating_thunks(cgraph_node*)
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cgraphclones.c:262
0x120434557 cgraph_node::create_clone(tree_node*, profile_count, bool,
vec, bool, cgraph_node*, ipa_param_adjustments*,
char const*)
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cgraphclones.c:427
0x12043497b cgraph_node::create_virtual_clone(vec, vec*, ipa_param_adjustments*, char
const*, unsigned int)
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/cgraphclones.c:613
0x1205ee357 process_isra_node_results
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/ipa-sra.c:3811
0x1205ee357 ipa_sra_analysis
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/ipa-sra.c:4047
0x1205ee357 execute
/home/ncopa/aports/main/gcc/src/gcc-10.2.1/gcc/ipa-sra.c:4099
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
make: *** [Makefile:1117: cp/method.o] Error 1

Withs some help from Ariadne we figured out that

 it passes with -O1
 it fails with -O2 (or -Os)
 it fails with -O1 -fipa-sra -fpartial-inlining
 it fails with -Og -fipa-sra -fpartial-inlining
 it passes with -Og -fipa-sra
 it passes with -Og -fpartial-inlining
 it passes with -O2  and either -fnoipa-sra or -fnopartial-inlining
 it passes with -fipa-sra -fpartial-inlining


So it seems that it is some -Og optimization in combination with -fipa-sra
-fpartial-inlining triggers it. I have not been able to pinpoint any of the
documented -O1 or -Og optimization flags.

It fails with:
-Og -fipa-sra -fpartial-inlining  -fno-combine-stack-adjustments
-fno-compare-elim -fno-cprop-registers -fno-defer-pop -fno-ipa-profile
-fno-ipa-pure-const -fno-ipa-reference -fno-ipa-reference-addressable
-fno-merge-constants -fno-omit-frame-pointer -fno-reorder-blocks
-fno-shrink-wrap -fno-split-wide-types -fno-tree-builtin-call-dce -fno-tree-ccp
-fno-tree-ch -fno-tree-coalesce-vars -fno-tree-copy-prop -fno-tree-dce
-fno-tree-dominator-opts -fno-tree-fre -fno-tree-sink -fno-tree-slsr
-fno-tree-ter