https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113204

--- Comment #6 from Sam James <sjames at gcc dot gnu.org> ---
I managed to run the test manually in `/usr/lib/go/src/cmd/link` with `go test
cgo_test.go -x -v` and made writeTempFile dump the name/contents.

At least now I can reproduce with just one command outside of the test suite:
```
/tmp/go-test $ cat add.go
package main

import "C"

/* test */

//export myadd
func myadd(a C.int, b C.int) C.int {
        return a + b
}
```

```
/tmp/go-test $ cat main.go
package main

import "fmt"

/*
#include <stdio.h>

void hello(void) {
  printf("hello\n");
}
*/
import "C"

func main() {
        hello := C.hello
        fmt.Printf("%v\n", hello)
}
```

```
/tmp/go-test $ cat go.mod
module cgolto
```


Then I get:
```
/tmp/go-test $ CGO_CFLAGS="-O2 -g -flto" /usr/lib/go/bin/go build
# cgolto
/usr/lib/go/pkg/tool/linux_amd64/link: running x86_64-pc-linux-gnu-gcc failed:
exit status 1
lto1: error: qsort comparator non-negative on sorted output: 64
during IPA pass: static-var
lto1: internal compiler error: qsort checking failed
0x63b5c1913cd6 qsort_chk_error
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/vec.cc:204
0x63b5c0397d4d qsort_chk(void*, unsigned long, unsigned long, int (*)(void
const*, void const*, void*), void*)
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/vec.cc:246
0x63b5c1d34457 gcc_sort_r(void*, unsigned long, unsigned long, int (*)(void
const*, void const*, void*), void*)
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/sort.cc:296
0x63b5c1b289f4 vec<symtab_node*, va_heap, vl_embed>::sort(int (*)(void const*,
void const*, void*), void*)
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/vec.h:1232
0x63b5c1b289f4 vec<symtab_node*, va_heap, vl_ptr>::sort(int (*)(void const*,
void const*, void*), void*)
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/vec.h:2252
0x63b5c1b289f4 lto_output()
       
/usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto-streamer-out.cc:2799
0x63b5c21e6365 write_lto
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/passes.cc:2779
0x63b5c21e2c9e ipa_write_optimization_summaries(lto_symtab_encoder_d*)
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/passes.cc:2969
0x63b5c21e1f94 stream_out
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:179
0x63b5c21e1f94 stream_out_partitions_1
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:231
0x63b5c21abd7a stream_out_partitions
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:246
0x63b5c21abd7a lto_wpa_write_files
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:419
0x63b5c21abd7a do_whole_program_analysis
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:594
0x63b5c21abd7a lto_main()
        /usr/src/debug/sys-devel/gcc-14.0.9999/gcc-14.0.9999/gcc/lto/lto.cc:668
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
lto-wrapper: fatal error: x86_64-pc-linux-gnu-gcc returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status
```

Reply via email to