Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Nov 2019 02:20:43 +0000
From:      Dennis Clarke <dclarke@blastwave.org>
To:        Ruslan Bukin <ruslan.bukin@cl.cam.ac.uk>, Bruce Hoult <brucehoult@sifive.com>
Cc:        RISC-V SW Dev <sw-dev@groups.riscv.org>, freebsd-riscv <freebsd-riscv@freebsd.org>
Subject:   clang dumps core on FreeBSD rv64imafdc
Message-ID:  <2a767be9-c6f6-498b-5054-0e01a912cd7a@blastwave.org>
In-Reply-To: <20191127135941.GA20804@bsdpad.com>
References:  <5bca6745-1c09-3ba7-3b4a-2456ea2e1081@blastwave.org> <CAP8PnuRf0MnN=Lik7MjUsJ_tETNkx7zrBk0GgQ=WZSSqsBSdFw@mail.gmail.com> <20191127135941.GA20804@bsdpad.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 11/27/19 1:59 PM, Ruslan Bukin wrote:
> The gcc we use is not old, but 8.3.0:
> http://svn.freebsd.org/ports/head/devel/riscv64-gcc/Makefile
>

OKay I will go back and have another look at that.

For the record clang currently dumps core on FreeBSD rv64imafdc :

rv64$ uname -a
FreeBSD callisto 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r355009: Mon Nov 
25 04:02:43 GMT 2019 
root@vesta:/opt/rv64/obj/usr/src/20191122121007/freebsd-riscv/riscv.riscv64/sys/QEMU 
  riscv
rv64$

rv64$ /usr/bin/clang --version
FreeBSD clang version 9.0.0 (tags/RELEASE_900/final 372316) (based on 
LLVM 9.0.0)
Target: riscv64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
rv64$

rv64$
rv64$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main ( int argc, char **argv)
{

     uint64_t foo = 0xfeeddeadbeef;

     printf ( "have a sandwich %lld\n", foo );

     return ( 0x42 );

}
rv64$

rv64$ ls -lapbin /usr/bin/cc /usr/bin/clang
613 -r-xr-xr-x  4 0  0  63383544 Nov 26 08:00 /usr/bin/cc
613 -r-xr-xr-x  4 0  0  63383544 Nov 26 08:00 /usr/bin/clang
rv64$

rv64$ echo $CC
/usr/bin/cc
rv64$ echo $CFLAGS
-std=iso9899:1999 -O0 -fno-builtin -march=rv64imafdc -mabi=lp64d 
-mstrict-align
rv64$ echo $CPPFLAGS
-D_TS_ERRNO -D_POSIX_PTHREAD_SEMANTIC -D_LARGEFILE64_SOURCE 
-D_XOPEN_SOURCE=600
rv64$

rv64$ $CC $CFLAGS $CPPFLAGS -E -o hello.i hello.s


Seems to produce reasonable output.

rv64$
rv64$ $CC $CFLAGS $CPPFLAGS -S -o hello.s hello.i
cc: warning: argument unused during compilation: '-mstrict-align' 
[-Wunused-command-line-argument]


Assertion failed: (*(NamedDecl **)&Data == ND && "PointerUnion mangles 
the NamedDecl pointer!"), function setOnlyValue, file 
/usr/src/20191122121007/freebsd-riscv/contrib/llvm/tools/clang/include/clang/AST/DeclContextInternals.h, 
line 103.
Stack dump:
0.      Program arguments: /usr/bin/cc -cc1 -triple 
riscv64-unknown-freebsd13.0 -S -disable-free -main-file-name hello.i 
-mrelocation-model static -mthread-model posix -mdisable-fp-elim 
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array 
-target-feature +m -target-feature +a -target-feature +f -target-feature 
+d -target-feature +c -target-feature +relax -target-abi lp64d 
-dwarf-column-info -debugger-tuning=gdb -coverage-notes-file 
/home/dclarke/hello.gcno -resource-dir /usr/lib/clang/9.0.0 -O0 
-std=iso9899:1999 -fdebug-compilation-dir /home/dclarke -ferror-limit 19 
-fmessage-length 132 -fno-builtin -fno-signed-char 
-fobjc-runtime=gnustep -fdiagnostics-show-option -faddrsig -o hello.s -x 
cpp-output hello.i
1.      /usr/include/stdio.h:459:15: current parser token '>='
2.      /usr/include/stdio.h:458:47: parsing function body '__sputc'
3.      /usr/include/stdio.h:458:47: in compound statement ('{}')
cc: error: unable to execute command: Abort trap (core dumped)
cc: error: clang frontend command failed due to signal (use -v to see 
invocation)
FreeBSD clang version 9.0.0 (tags/RELEASE_900/final 372316) (based on 
LLVM 9.0.0)
Target: riscv64-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
cc: note: diagnostic msg: PLEASE submit a bug report to 
https://bugs.freebsd.org/submit/ and include the crash backtrace, 
preprocessed source, and associated run script.
cc: note: diagnostic msg: Error generating preprocessed source(s) - no 
preprocessable inputs.
rv64$

rv64$
rv64$ ls -la cc.core
-rw-------  1 dclarke  devl  12701696 Nov 28 01:24 cc.core
rv64$ file cc.core
cc.core: ELF 64-bit LSB core file, UCB RISC-V, version 1 (FreeBSD), 
FreeBSD-style, from '/usr/bin/cc -cc1 -triple 
riscv64-unknown-freebsd13.0 -S -disable-free -main-file', pid=823
rv64$


So the good news is that your older gcc seems to be working fine. A bit 
confused about where to find libs but works just fine thus far.

rv64$
rv64$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main ( int argc, char **argv)
{

     uint64_t foo = 0xfeeddeadbeef;

     printf ( "have a sandwich %lld\n", foo );

     return ( 0x42 );

}
rv64$ /usr/local/bin/gcc -v -std=iso9899:1999 -O0 -fno-builtin 
-march=rv64imafdc -mabi=lp64d -L/usr/local/lib -L/lib -o hello hello.c
Using built-in specs.
COLLECT_GCC=/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/lto-wrapper
Target: riscv64-unknown-freebsd12.0
Configured with: 
/home/br/dev/riscv20181213/riscv-gnu-toolchain/riscv-gcc/configure 
--target=riscv64-unknown-freebsd12.0 --host=riscv64-unknown-freebsd12.0 
--with-build-sysroot=/home/br/riscv-world --without-newlib 
--without-headers --disable-werror --disable-shared --enable-threads 
--enable-tls --enable-languages=c,c++ 
--with-gmp=/home/br/riscv-world/usr/local 
--with-mpfr=/home/br/riscv-world/usr/local 
--with-mpc=/home/br/riscv-world/usr/local --disable-libatomic 
--disable-libmudflap --disable-libssp --disable-libquadmath 
--disable-libgomp --disable-nls --disable-bootstrap --disable-multilib 
--with-arch=rv64imafdc
Thread model: posix
gcc version 8.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-O0' '-fno-builtin' 
'-march=rv64imafdc' '-mabi=lp64d' '-L/usr/local/lib' '-L/lib' '-o' 'hello'
  /usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/cc1 -quiet -v 
hello.c -quiet -dumpbase hello.c -march=rv64imafdc -mabi=lp64d -auxbase 
hello -O0 -std=c99 -version -fno-builtin -o /var/tmp/dclarke/ccGbO6Xa.s
GNU C99 (GCC) version 8.2.0 (riscv64-unknown-freebsd12.0)
         compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR 
version 4.0.1, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory 
"/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/../../../../riscv64-unknown-freebsd12.0/include"
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/include
  /usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/include-fixed
  /usr/include
End of search list.
GNU C99 (GCC) version 8.2.0 (riscv64-unknown-freebsd12.0)
         compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR 
version 4.0.1, MPC version 1.1.0, isl version none
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4dda19917b6f288652be2776fcfdf247
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-O0' '-fno-builtin' 
'-march=rv64imafdc' '-mabi=lp64d' '-L/usr/local/lib' '-L/lib' '-o' 'hello'
 
/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/../../../../riscv64-unknown-freebsd12.0/bin/as 
-v --traditional-format -march=rv64imafdc -mabi=lp64d -o 
/var/tmp/dclarke/ccqQ7cBB.o /var/tmp/dclarke/ccGbO6Xa.s
GNU assembler version 2.31.1 (riscv64-unknown-freebsd12.0) using BFD 
version (GNU Binutils) 2.31.1
COMPILER_PATH=/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/:/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/:/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/:/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/:/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/:/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/../../../../riscv64-unknown-freebsd12.0/bin/
LIBRARY_PATH=/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/:/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/../../../../riscv64-unknown-freebsd12.0/lib/:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-O0' '-fno-builtin' 
'-march=rv64imafdc' '-mabi=lp64d' '-L/usr/local/lib' '-L/lib' '-o' 'hello'
  /usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/collect2 
-plugin 
/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/liblto_plugin.so 
-plugin-opt=/usr/local/libexec/gcc/riscv64-unknown-freebsd12.0/8.2.0/lto-wrapper 
-plugin-opt=-fresolution=/var/tmp/dclarke/ccjoEC0T.res 
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc 
-plugin-opt=-pass-through=-lgcc --eh-frame-hdr -melf64lriscv -V 
-dynamic-linker /libexec/ld-elf.so.1 -o hello /usr/lib/crt1.o 
/usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/local/lib -L/lib 
-L/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0 
-L/usr/local/lib/gcc/riscv64-unknown-freebsd12.0/8.2.0/../../../../riscv64-unknown-freebsd12.0/lib 
/var/tmp/dclarke/ccqQ7cBB.o -lgcc -lc -lgcc /usr/lib/crtend.o 
/usr/lib/crtn.o
GNU ld (GNU Binutils) 2.31.1
   Supported emulations:
    elf64lriscv
    elf32lriscv
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-O0' '-fno-builtin' 
'-march=rv64imafdc' '-mabi=lp64d' '-L/usr/local/lib' '-L/lib' '-o' 'hello'
rv64$ ./hello
have a sandwich 280297596632815
rv64$ echo $?
66
rv64$

rv64$
rv64$ uname -apKU
FreeBSD callisto 13.0-CURRENT FreeBSD 13.0-CURRENT #0 r355009: Mon Nov 
25 04:02:43 GMT 2019 
root@vesta:/opt/rv64/obj/usr/src/20191122121007/freebsd-riscv/riscv.riscv64/sys/QEMU 
  riscv riscv64 1300061 1300061
rv64$
rv64$ /usr/local/bin/gcc --version
gcc (GCC) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

rv64$ cat pi.c

#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

int main(int argc, char *argv[])
{

     long double *pi;

     int j = 1;  /* dummy test integer */
     int little_endian = (*(uint8_t*)&j == 1) ? 1 : 0;

     printf("the sizeof(long double pi) is %lld bytes\n",
                                         sizeof(long double) );

     pi = calloc ( (size_t)1, sizeof(long double) );
     *pi = 3.141592653589793238462643383279502884197L;

     if (little_endian) {
         printf("\nThis is a little endian memory machine.\n");
         printf("Data in memory may be reversed.\n");
         printf("Here is the data in natural human order.\n");
         printf("0x%" PRIXPTR " : ", (uintptr_t)pi);
         for ( j=(sizeof(long double)-1); j>(-1); j-- )
             printf("%02x ", (uint8_t)((uint8_t*)pi)[j] );

     } else {
         printf("\nThis is a big endian memory machine.\n");
         printf("0x%" PRIXPTR " : ", (uintptr_t)pi);
         for ( j=0; j<sizeof(long double); j++ )
             printf("%02x ", (uint8_t)((uint8_t*)pi)[j] );

     }
     printf("\n\n" );

     printf("pi could be decimal %42.38Le\n", *pi);

     return ( EXIT_SUCCESS );

}

rv64$ /usr/local/bin/gcc $CFLAGS -L/usr/lib -L/lib -L/usr/local/lib -o 
pi pi.c
rv64$ ./pi
the sizeof(long double pi) is 16 bytes

This is a little endian memory machine.
Data in memory may be reversed.
Here is the data in natural human order.
0x402D0000 : 40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8

pi could be decimal 2.00000766687026546771356836744283183073e+00
rv64$


However ye old Fujitsu SPARCv9 boxen :

beta$
beta$ uname -a
SunOS beta 5.10 Generic_150400-65 sun4u sparc SUNW,SPARC-Enterprise
beta$ echo $CC
/opt/developerstudio12.6/bin/c99
beta$ echo $CFLAGS
-m64 -xarch=sparc -Xc -g -mc -xs -errfmt=error -erroff=%none 
-errshort=full -errtags=yes -errwarn=%none -ftrap=%none -xbuiltin=%none 
-xildoff -xlibmieee -xstrconst -xcode=pic32 -xmemalign=8s -xnolibmil 
-xunroll=1 -xregs=no%appl -xdebugformat=dwarf
beta$ echo $CPPFLAGS
-I/usr/local/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE 
-D_TS_ERRNO
beta$
beta$ $CC $CFLAGS $CPPFLAGS -o pi pi_foo.c
beta$
beta$ ./pi
the sizeof(long double pi) is 16 bytes

This is a big endian memory machine.
0x1001012D0 : 40 00 92 1f b5 44 42 d1 84 69 89 8c c5 17 01 b8

pi could be decimal 3.14159265358979323846264338327950279748e+00
beta$

Thus pi = 2.000 here on FreeBSD RISC-V :)


-- 
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2a767be9-c6f6-498b-5054-0e01a912cd7a>