I can't send '-march=native' to gcc from CGo

Hi all,

Thanks for reading this.

I’m unable to set the ‘-march=native’ compiler flag from CGo.

CGo is ignoring the setting no matter what I do. I’ve also tried setting the ‘GO_ARCH’ environment variable and I’ve set the ‘CGO_FLAGS_ALLOW’ environment variable correctly. The command ‘go tool cgo -debug-gcc’ tells me that Go is replacing the ‘-march=native’ with ‘-m64’.

To reproduce:

//go:build amd64 && !purego && gc
    // +build amd64,!purego,gc

    // #cgo CFLAGS: -march=native

    package keccakAVX512

    /*
    // check if the amd64 machine supports AVX512 instructions at build time and call
    // an assembly function using AVX512 if so.


    #ifdef __AVX2__
        void keccakF1600_AVX512(unsigned long* state);

    this should fail with a syntax error but doesn't
    #endif

    //      void keccakF1600_AVX512(unsigned long* state) {};
    */
    import "C"

    func KeccakF1600AMDAVX512(a *[25]uint64) {
        C.keccakF1600_AVX512((*C.ulong)(&a[0]))
    }

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.