oh yes, I am using gccgo. I configured gccgo from source. Below is the go version output: *go version go1.10.3 gccgo (GCC) 8.2.1 20180814 solaris/sparc *
Following is the output of what is -bash-3.2$ go build -x sol10.go WORK=/tmp/go-build151901300 mkdir -p $WORK/b001/ cd $WORK /usr/gnu/bin/gccgo -fsplit-stack -c -x c - || true cd /export/home/amandeep CGO_LDFLAGS='"-g" "-O2"' /usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1/cgo -objdir $WORK/b001/ -importpath command-line-arguments -gccgo -- -I $WORK/b001/ -g -O2 ./sol10.go # command-line-arguments ./sol10.go:15:5: call of non-function C.testc As suggested, next I ran with -debug-gcc option: -bash-3.2$ CGO_LDFLAGS='"-g" "-O2"' /usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1/cgo -debug-gcc -objdir $WORK/b001/ -importpath command-line-arguments -gccgo -- -I $WORK/b001/ -g -O2 ./sol10.go $ gcc -E -dM -xc -I /b001/ -g -O2 - <<EOF #line 1 "cgo-builtin-prolog" #include <stddef.h> /* for ptrdiff_t and size_t below */ /* Define intgo when compiling with GCC. */ typedef ptrdiff_t intgo; typedef struct { const char *p; intgo n; } _GoString_; typedef struct { char *p; intgo n; intgo c; } _GoBytes_; _GoString_ GoString(char *p); _GoString_ GoStringN(char *p, int l); _GoBytes_ GoBytes(void *p, int n); char *CString(_GoString_); void *CBytes(_GoBytes_); void *_CMalloc(size_t); __attribute__ ((unused)) static size_t _GoStringLen(_GoString_ s) { return s.n; } __attribute__ ((unused)) static const char *_GoStringPtr(_GoString_ s) { return s.p; } #line 3 "/export/home/amandeep/sol10.go" #include <stdio.h> void testc() { printf("Hello cgo"); } #line 1 "cgo-generated-wrapper" EOF #define __DBL_MIN_EXP__ (-1021) #define __FLT32X_MAX_EXP__ 1024 #define _SYS_FEATURE_TESTS_H #define __UINT_LEAST16_MAX__ 0xffff #define __ATOMIC_ACQUIRE 2 #define __FLT128_MAX_10_EXP__ 4932 #define __sun_attr___packed__ __attribute__((__packed__)) #define __FLT_MIN__ 1.17549435082228750796873653722224568e-38F #define __GCC_IEC_559_COMPLEX 2 #define __UINT_LEAST8_TYPE__ unsigned char #define _T_WCHAR_ #define __INTMAX_C(c) c ## LL #define __CHAR_BIT__ 8 #define __UINT8_MAX__ 0xff #define __sun_attr___VPRINTFLIKE__(__n) __attribute__((__format__(printf, __n, 0))) #define _FILEDEFED #define __WINT_MAX__ 0x7fffffffL #define __FLT32_MIN_EXP__ (-125) #define stderr (&__iob[2]) #define __ORDER_LITTLE_ENDIAN__ 1234 #define __SIZE_MAX__ 0xffffffffU #define __WCHAR_MAX__ 0x7fffffffL #define _LONG_LONG_ALIGNMENT 8 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 #define __DBL_DENORM_MIN__ ((double)4.94065645841246544176568792868221372e-324L) #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 #define __GCC_ATOMIC_CHAR_LOCK_FREE 2 #define _OBP #define __GCC_IEC_559 2 #define __FLT32X_DECIMAL_DIG__ 17 #define _IOFBF 0000 #define __sun_attr___pure__ __attribute__((__pure__)) #define __FLT_EVAL_METHOD__ 0 #define __unix__ 1 #define __FLT64_DECIMAL_DIG__ 17 #define _XOPEN_VERSION 3 #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 #define __UINT_FAST64_MAX__ 0xffffffffffffffffULL #define __SIG_ATOMIC_TYPE__ int #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define L_cuserid 9 #define ___sun_attr_inner(__a) __sun_attr_ ##__a #define __sun_attr___noreturn__ __attribute__((__noreturn__)) #define __GNUC_PATCHLEVEL__ 1 #define __FLT32_HAS_DENORM__ 1 #define __UINT_FAST8_MAX__ 0xff #define __has_include(STR) __has_include__(STR) #define __size_t #define __DEC64_MAX_EXP__ 385 #define _WCHAR_T_DEFINED #define __INT8_C(c) c #define __INT_LEAST8_WIDTH__ 8 #define sparc 1 #define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL #define __sun_attr__(__a) ___sun_attr_inner __a #define __SHRT_MAX__ 0x7fff #define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L #define __FLT64X_MAX_10_EXP__ 4932 #define __UINT_LEAST8_MAX__ 0xff #define __GCC_ATOMIC_BOOL_LOCK_FREE 2 #define __FLT128_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F128 #define __UINTMAX_TYPE__ long long unsigned int #define __DEC32_EPSILON__ 1E-6DF #define __FLT_EVAL_METHOD_TS_18661_3__ 0 #define __OPTIMIZE__ 1 #define putchar(x) putc((x), stdout) #define __unix 1 #define __UINT32_MAX__ 0xffffffffU #define __SIZE_T #define __LDBL_MAX_EXP__ 16384 #define __FLT128_MIN_EXP__ (-16381) #define __WINT_MIN__ (-__WINT_MAX__ - 1) #define __sun 1 #define __FLT128_MIN_10_EXP__ (-4931) #define __INT_LEAST16_WIDTH__ 16 #define _SIZE_T_DEFINED_ #define __SCHAR_MAX__ 0x7f #define _LONG_ALIGNMENT 4 #define __FLT128_MANT_DIG__ 113 #define __WCHAR_MIN__ (-__WCHAR_MAX__ - 1) #define __INT64_C(c) c ## LL #define _INT_ALIGNMENT 4 #define __DBL_DIG__ 15 #define __GCC_ATOMIC_POINTER_LOCK_FREE 2 #define __FLT64X_MANT_DIG__ 113 #define _SYS_CCOMPILE_H #define getchar() getc(stdin) #define __SIZEOF_INT__ 4 #define __SIZEOF_POINTER__ 4 #define clearerr(p) ((void)((p)->_flag &= ~(_IOERR | _IOEOF))) #define _DOUBLE_COMPLEX_ALIGNMENT 8 #define __USER_LABEL_PREFIX__ #define __FLT64X_EPSILON__ 1.92592994438723585305597794258492732e-34F64x #define __STDC_HOSTED__ 1 #define __LDBL_HAS_INFINITY__ 1 #define _BSD_SIZE_T_DEFINED_ #define __FLT32_DIG__ 6 #define __FLT_EPSILON__ 1.19209289550781250000000000000000000e-7F #define __SHRT_WIDTH__ 16 #define TMP_MAX 17576 #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L #define __STDC_UTF_16__ 1 #define __DEC32_MAX__ 9.999999E96DF #define _WCHAR_T_ #define __FLT64X_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966F64x #define _STDDEF_H #define __FLT32X_HAS_INFINITY__ 1 #define __INT32_MAX__ 0x7fffffff #define __INT_WIDTH__ 32 #define __SIZEOF_LONG__ 4 #define _IONBF 0004 #define __UINT16_C(c) c #define __PTRDIFF_WIDTH__ 32 #define __DECIMAL_DIG__ 36 #define __FLT64_EPSILON__ 2.22044604925031308084726333618164062e-16F64 #define __INTMAX_WIDTH__ 64 #define _LARGEFILE_SOURCE 1 #define __has_include_next(STR) __has_include_next__(STR) #define __FLT64X_MIN_10_EXP__ (-4931) #define __LDBL_HAS_QUIET_NAN__ 1 #define __FLT64_MANT_DIG__ 53 #define __va_ptr_base void #define L_tmpnam 25 #define ___int_wchar_t_h #define _T_PTRDIFF #define __GNUC__ 8 #define __sun_attr___KVPRINTFLIKE__(__n) __attribute__((__format__(cmn_err, __n, 0))) #define offsetof(TYPE,MEMBER) __builtin_offsetof (TYPE, MEMBER) #define L_ctermid 9 #define __FLT_HAS_DENORM__ 1 #define __SIZEOF_LONG_DOUBLE__ 16 #define SEEK_CUR 1 #define __BIGGEST_ALIGNMENT__ 8 #define __FLT64_MAX_10_EXP__ 308 #define __sun_attr___KPRINTFLIKE__(__n) __attribute__((__format__(cmn_err, __n, (__n)+1))) #define __va_void(expr) ((void)expr) #define _STDIO_H #define __DBL_MAX__ ((double)1.79769313486231570814527423731704357e+308L) #define __INT_FAST32_MAX__ 0x7fffffff #define __DBL_HAS_INFINITY__ 1 #define stdin (&__iob[0]) #define __SVR4 1 #define __DEC32_MIN_EXP__ (-94) #define __INTPTR_WIDTH__ 32 #define _LONG_LONG_HTOL #define __FLT32X_HAS_DENORM__ 1 #define __INT_FAST16_TYPE__ int #define _SIZE_T_DEFINED #define _SUNOS_VTOC_8 #define _WCHAR_T_DEFINED_ #define _NFILE 20 #define __LDBL_HAS_DENORM__ 1 #define _STDIO_IMPL_H #define __va_alist_type int #define __FLT128_HAS_INFINITY__ 1 #define __DEC128_MAX__ 9.999999999999999999999999999999999E6144DL #define __INT_LEAST32_MAX__ 0x7fffffff #define _LONG_LONG_ALIGNMENT_32 _LONG_LONG_ALIGNMENT #define __DEC32_MIN__ 1E-95DF #define __DBL_MAX_EXP__ 1024 #define __WCHAR_WIDTH__ 32 #define __FLT32_MAX__ 3.40282346638528859811704183484516925e+38F32 #define __DEC128_EPSILON__ 1E-33DL #define __PTRDIFF_MAX__ 0x7fffffff #define _STDIO_TAG_H #define _PTRDIFF_T_DECLARED #define __FLT32_HAS_QUIET_NAN__ 1 #define _T_WCHAR #define __LONG_LONG_MAX__ 0x7fffffffffffffffLL #define __SIZEOF_SIZE_T__ 4 #define _WCHAR_T #define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n))) #define __sparc__ 1 #define __FLT64X_MIN_EXP__ (-16381) #define __SIZEOF_WINT_T__ 4 #define __LONG_LONG_WIDTH__ 64 #define _GCC_WCHAR_T #define __FLT32_MAX_EXP__ 128 #define _PTRDIFF_T #define __GXX_ABI_VERSION 1013 #define __sun_attr___PRINTFLIKE__(__n) __attribute__((__format__(printf, __n, (__n)+1))) #define __FLT_MIN_EXP__ (-125) #define __PTRDIFF_T #define __FLT64X_HAS_QUIET_NAN__ 1 #define __INT_FAST64_TYPE__ long long int #define _LONGLONG_TYPE #define __FILE_TAG __FILE #define ferror(p) ((p)->_flag & _IOERR) #define _ANSI_STDDEF_H #define __FLT64_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F64 #define __DBL_MIN__ ((double)2.22507385850720138309023271733240406e-308L) #define _ALIGNMENT_REQUIRED 1 #define __FLT32X_EPSILON__ 2.22044604925031308084726333618164062e-16F32x #define _ISO_STDIO_ISO_H #define __FLT64_MIN_EXP__ (-1021) #define _RESTRICT_KYWD restrict #define _SYS_ISA_DEFS_H #define __FLT64_MIN_10_EXP__ (-307) #define _IOREAD 0001 #define __FLT64X_DECIMAL_DIG__ 36 #define __DEC128_MIN__ 1E-6143DL #define __REGISTER_PREFIX__ #define __UINT16_MAX__ 0xffff #define _LONG_DOUBLE_ALIGNMENT 8 #define __DBL_HAS_DENORM__ 1 #define _IOMYBUF 0010 #define __FLT32_MIN__ 1.17549435082228750796873653722224568e-38F32 #define __UINT8_TYPE__ unsigned char #define __sparcv8 1 #define __sun_attr___const__ __attribute__((__const__)) #define __FLT_MANT_DIG__ 24 #define __LDBL_DECIMAL_DIG__ 36 #define __VERSION__ "8.2.1 20180814" #define __UINT64_C(c) c ## ULL #define _PTRDIFF_T_ #define __INT_WCHAR_T_H #define _BIT_FIELDS_HTOL #define __GCC_ATOMIC_INT_LOCK_FREE 2 #define _NO_FDISK_PRESENT #define _T_PTRDIFF_ #define __FLT128_MAX_EXP__ 16384 #define __FLT32_MANT_DIG__ 24 #define _SYS_SIZE_T_H #define _OFF_T #define __FLOAT_WORD_ORDER__ __ORDER_BIG_ENDIAN__ #define __SIZE_T__ #define _CHAR_ALIGNMENT 1 #define __FLT128_HAS_DENORM__ 1 #define __sparc 1 #define __FLT128_DIG__ 33 #define __SCHAR_WIDTH__ 8 #define __INT32_C(c) c #define __DEC64_EPSILON__ 1E-15DD #define __ORDER_PDP_ENDIAN__ 3412 #define __DEC128_MIN_EXP__ (-6142) #define __FLT32_MAX_10_EXP__ 38 #define sun 1 #define __INT_FAST32_TYPE__ int #define __UINT_LEAST16_TYPE__ short unsigned int #define __FLT64X_HAS_INFINITY__ 1 #define unix 1 #define __INT16_MAX__ 0x7fff #define _BSD_SIZE_T_ #define __SIZE_TYPE__ unsigned int #define __UINT64_MAX__ 0xffffffffffffffffULL #define _SIZE_T_DECLARED #define _ISO_STDIO_C99_H #define _FLOAT_ALIGNMENT 4 #define __FLT64X_DIG__ 33 #define __INT8_TYPE__ char #define _IORW 0200 #define __ELF__ 1 #define _FLOAT_COMPLEX_ALIGNMENT 4 #define __FLT_RADIX__ 2 #define __INT_LEAST16_TYPE__ short int #define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L #define __UINTMAX_C(c) c ## ULL #define __SIG_ATOMIC_MAX__ 0x7fffffff #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 #define _BOOL_ALIGNMENT 1 #define __SIZEOF_PTRDIFF_T__ 4 #define SEEK_SET 0 #define _HAVE_TEM_FIRMWARE #define _SYS_VA_LIST_H #define _STDC_C99 #define __FLT32X_MANT_DIG__ 53 #define _SIZE_T_ #define __FLT32X_MIN_EXP__ (-1021) #define __DEC32_SUBNORMAL_MIN__ 0.000001E-95DF #define _WCHAR_T_H #define __INT_FAST16_MAX__ 0x7fffffff #define __FLT64_DIG__ 15 #define __UINT_FAST32_MAX__ 0xffffffffU #define __UINT_LEAST64_TYPE__ long long unsigned int #define __FLT_HAS_QUIET_NAN__ 1 #define _MAX_ALIGNMENT 8 #define __FLT_MAX_10_EXP__ 38 #define _POINTER_ALIGNMENT 4 #define __LONG_MAX__ 0x7fffffffL #define __WCHAR_T__ #define __FLT64X_HAS_DENORM__ 1 #define __DEC128_SUBNORMAL_MIN__ 0.000000000000000000000000000000001E-6143DL #define __FLT_HAS_INFINITY__ 1 #define _BSD_PTRDIFF_T_ #define _ILP32 #define __UINT_FAST16_TYPE__ unsigned int #define __DEC64_MAX__ 9.999999999999999E384DD #define __INT_FAST32_WIDTH__ 32 #define NULL ((void *)0) #define __CHAR16_TYPE__ short unsigned int #define __PRAGMA_REDEFINE_EXTNAME 1 #define __SIZE_WIDTH__ 32 #define __INT_LEAST16_MAX__ 0x7fff #define __DEC64_MANT_DIG__ 16 #define __INT64_MAX__ 0x7fffffffffffffffLL #define __UINT_LEAST32_MAX__ 0xffffffffU #define __FLT32_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F32 #define __GCC_ATOMIC_LONG_LOCK_FREE 2 #define __SIG_ATOMIC_WIDTH__ 32 #define __INT_LEAST64_TYPE__ long long int #define __INT16_TYPE__ short int #define __INT_LEAST8_TYPE__ char #define __STDC_VERSION__ 201710L #define __DEC32_MAX_EXP__ 97 #define _BIG_ENDIAN #define __INT_FAST8_MAX__ 0x7f #define __FLT128_MAX__ 1.18973149535723176508575932662800702e+4932F128 #define __INTPTR_MAX__ 0x7fffffff #define __FLT64_HAS_QUIET_NAN__ 1 #define _IOLBF 0100 #define __FLT32_MIN_10_EXP__ (-37) #define __FLT32X_DIG__ 15 #define __LDBL_MANT_DIG__ 113 #define __DBL_HAS_QUIET_NAN__ 1 #define __FLT64_HAS_INFINITY__ 1 #define __FLT64X_MAX__ 1.18973149535723176508575932662800702e+4932F64x #define __GNUC_VA_LIST #define _GCC_MAX_ALIGN_T #define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1) #define _DOUBLE_ALIGNMENT 8 #define _SHORT_ALIGNMENT 2 #define FILENAME_MAX 1024 #define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n))) #define __INTPTR_TYPE__ int #define __UINT16_TYPE__ short unsigned int #define __WCHAR_TYPE__ long int #define __SIZEOF_FLOAT__ 4 #define __UINTPTR_MAX__ 0xffffffffU #define getc(p) (--(p)->_cnt < 0 ? __filbuf(p) : (int)*(p)->_ptr++) #define __INT_FAST64_WIDTH__ 64 #define __DEC64_MIN_EXP__ (-382) #define putc(x,p) (--(p)->_cnt < 0 ? __flsbuf((x), (p)) : (int)(*(p)->_ptr++ = (unsigned char) (x))) #define __FLT32_DECIMAL_DIG__ 9 #define __INT_FAST64_MAX__ 0x7fffffffffffffffLL #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 255 #define BUFSIZ 1024 #define __FLT_DIG__ 6 #define __FLT32_HAS_INFINITY__ 1 #define __FLT64X_MAX_EXP__ 16384 #define _IEEE_754 #define _WCHAR_T_DECLARED #define __UINT_FAST64_TYPE__ long long unsigned int #define __INT_MAX__ 0x7fffffff #define _DTRACE_VERSION 1 #define _T_SIZE_ #define feof(p) ((p)->_flag & _IOEOF) #define __INT64_TYPE__ long long int #define __FLT_MAX_EXP__ 128 #define __DBL_MANT_DIG__ 53 #define ___int_size_t_h #define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 #define _IOWRT 0002 #define __DEC64_MIN__ 1E-383DD #define __WINT_TYPE__ long int #define __UINT_LEAST32_TYPE__ unsigned int #define __SIZEOF_SHORT__ 2 #define __LDBL_MIN_EXP__ (-16381) #define __FLT64_MAX__ 1.79769313486231570814527423731704357e+308F64 #define stdout (&__iob[1]) #define __WINT_WIDTH__ 32 #define EOF (-1) #define __INT_LEAST8_MAX__ 0x7f #define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n))) #define __FLT32X_MAX_10_EXP__ 308 #define _CHAR_IS_SIGNED #define __LDBL_MAX_10_EXP__ 4932 #define __ATOMIC_RELAXED 0 #define __DBL_EPSILON__ ((double)2.22044604925031308084726333618164062e-16L) #define __FLT128_MIN__ 3.36210314311209350626267781732175260e-4932F128 #define _SIZET_ #define __UINT8_C(c) c #define __FLT64_MAX_EXP__ 1024 #define _LONG_DOUBLE_COMPLEX_ALIGNMENT 8 #define __INT_LEAST32_TYPE__ int #define __wchar_t__ #define __sun__ 1 #define SEEK_END 2 #define __SIZEOF_WCHAR_T__ 4 #define __UINT64_TYPE__ long long unsigned int #define _LARGEFILE64_SOURCE 1 #define _STDDEF_H_ #define __FLT128_HAS_QUIET_NAN__ 1 #define __INT_FAST8_TYPE__ char #define _IOEOF 0020 #define __FLT64X_MIN__ 3.36210314311209350626267781732175260e-4932F64x #define __GNUC_STDC_INLINE__ 1 #define P_tmpdir "/var/tmp/" #define __FLT64_HAS_DENORM__ 1 #define __FLT32_EPSILON__ 1.19209289550781250000000000000000000e-7F32 #define __DBL_DECIMAL_DIG__ 17 #define __STDC_UTF_32__ 1 #define _IOERR 0040 #define __INT_FAST8_WIDTH__ 8 #define __DEC_EVAL_METHOD__ 2 #define _SIZE_T #define __FLT32X_MAX__ 1.79769313486231570814527423731704357e+308F32x #define FOPEN_MAX _NFILE #define __PRINTFLIKE(__n) __sun_attr__((__PRINTFLIKE__(__n))) #define _STACK_GROWS_DOWNWARD #define _FILE_OFFSET_BITS 32 #define __svr4__ 1 #define _GCC_SIZE_T #define __ORDER_BIG_ENDIAN__ 4321 #define __UINT32_C(c) c ## U #define __INTMAX_MAX__ 0x7fffffffffffffffLL #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ #define __size_t__ #define __FLT_DENORM_MIN__ 1.40129846432481707092372958328991613e-45F #define __INT8_MAX__ 0x7f #define __LONG_WIDTH__ 32 #define __UINT_FAST32_TYPE__ unsigned int #define __CHAR32_TYPE__ unsigned int #define __FLT_MAX__ 3.40282346638528859811704183484516925e+38F #define __NORETURN __sun_attr__((__noreturn__)) #define __INT32_TYPE__ int #define _DMA_USES_VIRTADDR #define __SIZEOF_DOUBLE__ 8 #define __FLT_MIN_10_EXP__ (-37) #define _ISO_CPP_14882_1998 #define __FLT64_MIN__ 2.22507385850720138309023271733240406e-308F64 #define __INT_LEAST32_WIDTH__ 32 #define __INTMAX_TYPE__ long long int #define __DEC128_MAX_EXP__ 6145 #define _T_SIZE #define _ISO_C_9899_1999 #define __FLT32X_HAS_QUIET_NAN__ 1 #define __ATOMIC_CONSUME 1 #define __GNUC_MINOR__ 2 #define __INT_FAST16_WIDTH__ 32 #define __UINTMAX_MAX__ 0xffffffffffffffffULL #define __DEC32_MANT_DIG__ 7 #define __FLT32X_DENORM_MIN__ 4.94065645841246544176568792868221372e-324F32x #define __DBL_MAX_10_EXP__ 308 #define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L #define __INT16_C(c) c #define __PTRDIFF_TYPE__ int #define __CONST __sun_attr__((__const__)) #define __GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #define __ATOMIC_SEQ_CST 5 #define __UINT32_TYPE__ unsigned int #define __FLT32X_MIN_10_EXP__ (-307) #define __UINTPTR_TYPE__ unsigned int #define __DEC64_SUBNORMAL_MIN__ 0.000000000000001E-383DD #define __DEC128_MANT_DIG__ 34 #define __LDBL_MIN_10_EXP__ (-4931) #define __FLT128_EPSILON__ 1.92592994438723585305597794258492732e-34F128 #define __SIZEOF_LONG_LONG__ 8 #define _GCC_PTRDIFF_T #define _SBFSIZ 8 #define __FLT128_DECIMAL_DIG__ 36 #define __GCC_ATOMIC_LLONG_LOCK_FREE 2 #define __FLT32X_MIN__ 2.22507385850720138309023271733240406e-308F32x #define __LDBL_DIG__ 33 #define __FLT_DECIMAL_DIG__ 9 #define __UINT_FAST16_MAX__ 0xffffffffU #define ___int_ptrdiff_t_h #define __GCC_ATOMIC_SHORT_LOCK_FREE 2 #define __PURE __sun_attr__((__pure__)) #define __INT_LEAST64_WIDTH__ 64 #define __UINT_FAST8_TYPE__ unsigned char #define __ATOMIC_ACQ_REL 4 #define __WCHAR_T #define __ATOMIC_RELEASE 3 $ gcc -w -Wno-error -o/b001//_cgo_.o -gdwarf-2 -c -xc -I /b001/ -g - <<EOF #line 1 "cgo-builtin-prolog" #include <stddef.h> /* for ptrdiff_t and size_t below */ /* Define intgo when compiling with GCC. */ typedef ptrdiff_t intgo; typedef struct { const char *p; intgo n; } _GoString_; typedef struct { char *p; intgo n; intgo c; } _GoBytes_; _GoString_ GoString(char *p); _GoString_ GoStringN(char *p, int l); _GoBytes_ GoBytes(void *p, int n); char *CString(_GoString_); void *CBytes(_GoBytes_); void *_CMalloc(size_t); __attribute__ ((unused)) static size_t _GoStringLen(_GoString_ s) { return s.n; } __attribute__ ((unused)) static const char *_GoStringPtr(_GoString_ s) { return s.p; } #line 3 "/export/home/amandeep/sol10.go" #include <stdio.h> void testc() { printf("Hello cgo"); } #line 1 "cgo-generated-wrapper" #line 1 "not-declared" void __cgo_f_1_1(void) { __typeof__(testc) *__cgo_undefined__1; } #line 1 "not-type" void __cgo_f_1_2(void) { testc *__cgo_undefined__2; } #line 1 "not-int-const" void __cgo_f_1_3(void) { enum { __cgo_undefined__3 = (testc)*1 }; } #line 1 "not-num-const" void __cgo_f_1_4(void) { static const double __cgo_undefined__4 = (testc); } #line 1 "not-str-lit" void __cgo_f_1_5(void) { static const char __cgo_undefined__5[] = (testc); } #line 1 "completed" int __cgo__1 = __cgo__2; EOF not-type: In function '__cgo_f_1_2': not-type:1:33: error: '__cgo_undefined__2' undeclared (first use in this function); did you mean '__cgo_f_1_2'? not-type:1:33: note: each undeclared identifier is reported only once for each function it appears in not-int-const: In function '__cgo_f_1_3': not-int-const:1:61: error: invalid operands to binary * (have 'void (*)()' and 'int') not-num-const: In function '__cgo_f_1_4': not-num-const:1:67: error: incompatible types when initializing type 'double' using type 'void (*)()' not-str-lit: In function '__cgo_f_1_5': not-str-lit:1:67: error: invalid initializer completed: At top level: completed:1:16: error: '__cgo__2' undeclared here (not in a function); did you mean '__cgo__1'? completed:1:16: error: initializer element is not constant $ gcc -w -Wno-error -o/b001//_cgo_.o -gdwarf-2 -c -xc -I /b001/ -g -O2 - <<EOF #line 1 "cgo-builtin-prolog" #include <stddef.h> /* for ptrdiff_t and size_t below */ /* Define intgo when compiling with GCC. */ typedef ptrdiff_t intgo; typedef struct { const char *p; intgo n; } _GoString_; typedef struct { char *p; intgo n; intgo c; } _GoBytes_; _GoString_ GoString(char *p); _GoString_ GoStringN(char *p, int l); _GoBytes_ GoBytes(void *p, int n); char *CString(_GoString_); void *CBytes(_GoBytes_); void *_CMalloc(size_t); __attribute__ ((unused)) static size_t _GoStringLen(_GoString_ s) { return s.n; } __attribute__ ((unused)) static const char *_GoStringPtr(_GoString_ s) { return s.p; } #line 3 "/export/home/amandeep/sol10.go" #include <stdio.h> void testc() { printf("Hello cgo"); } #line 1 "cgo-generated-wrapper" #line 1 "cgo-dwarf-inference" __typeof__(testc) *__cgo__0; long long __cgodebug_ints[] = { 0, 1 }; double __cgodebug_floats[] = { 0, 1 }; EOF Assembler messages: Fatal error: can't create /b001//_cgo_.o: No such file or directory Assembler messages: Fatal error: can't create /b001//_cgo_.o: No such file or directory On Thursday, September 13, 2018 at 10:31:48 PM UTC-7, Ian Lance Taylor wrote: > > On Thu, Sep 13, 2018 at 7:16 PM, <aman...@cohesity.com <javascript:>> > wrote: > > > > Trying to compile the following on Solaris 10 gives the error: call of > > non-function C.testc > > > > package main > > > > /* > > #include <stdio.h> > > > > void testc() { > > printf("Hello cgo"); > > } > > */ > > import "C" > > > > func main() { > > C.testc() > > } > > > > The output of go env is below: > > bash-4.3$ go env > > GOARCH="sparc" > > GOBIN="" > > GOCACHE="/export/home/amandeep/.cache/go-build" > > GOEXE="" > > GOHOSTARCH="sparc" > > GOHOSTOS="solaris" > > GOOS="solaris" > > GOPATH="/export/home/amandeep/go" > > GORACE="" > > GOROOT="/usr/gnu" > > GOTMPDIR="" > > GOTOOLDIR="/usr/gnu/libexec/gcc/sparc-sun-solaris2.10/8.2.1" > > GCCGO="/usr/gnu/bin/gccgo" > > CC="gcc" > > CXX="g++" > > CGO_ENABLED="1" > > CGO_CFLAGS="-g -O2" > > CGO_CPPFLAGS="" > > CGO_CXXFLAGS="-g -O2" > > CGO_FFLAGS="-g -O2" > > CGO_LDFLAGS="-g -O2" > > PKG_CONFIG="pkg-config" > > GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 > > -fdebug-prefix-map=/tmp/go-build622699141=/tmp/go-build > > -gno-record-gcc-switches -funwind-tables" > > > > How can we debug the issue? What am I missing? a simple go file (without > > cgo) compiles and runs just fine. Additionally, this runs just fine on > > Solaris 11 as well. > > The cgo tool determines whether testc is a function based in part on > the debug info generated by the C compiler. It looks like you are > using GCC; what version of GCC are you using? > > You can make some progress in debugging this by running `go build -x` > to see exactly how cgo is invoked, then running that invocation and > adding the -debug-gcc option. > > Ian > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.