0

I've installed the CHERI simulator from this link.

It allows me to use the clang compiler for both risc-v and a capability extended risc-v architecture.

I've defined the following aliases

alias clang-riscv='~/cheri/output/sdk/bin/clang -g -O2 -target riscv64-unknown-freebsd --sysroot="~/cheri/output/rootfs-riscv64-purecap" -fuse-ld=lld -mno-relax -march=rv64gc -mabi=lp64d -Wall -Wcheri'

alias clang-cap='~/cheri/output/sdk/bin/clang -g -O2 -target riscv64-unknown-freebsd --sysroot="~/cheri/output/rootfs-riscv64-purecap" -fuse-ld=lld -mno-relax -march=rv64gcxcheri -mabi=l64pc128d -Wall -Wcheri'

Upon running the below commands, I get an error

$ clang-riscv print-pointer.c
print-pointer.c:5:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

$ clang-cap print-capability.c 
print-capability.c:5:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

I checked the sysroot/usr/include directory and it does contain stdio.h so I'm not sure why the linker is unable to find it.

sathvik@sathvik-Aspire-A515-51G:~/cheri/output/rootfs-riscv64-purecap/usr/include$ ls
aio.h               curses.h         fstab.h            krb5                 math.h         parse_time.h      rtld_db.h            syslog.h
alias.h             cuse.h           fts.h              krb5_asn1.h          md4.h          parse_units.h     runetype.h           taclib.h
a.out.h             db.h             ftw.h              krb5_ccapi.h         md5.h          pathconv.h        sched.h              tar.h
archive_entry.h     der.h            gcc                krb5_err.h           memory.h       paths.h           scsi_wrap.h          tcpd.h
archive.h           der-private.h    gelf.h             krb5.h               memstat.h      pcap              sdp.h                teken
ar.h                der-protos.h     geom               krb5-private.h       menu.h         pcap-bpf.h        search.h             termcap.h
arpa                dev              getarg.h           krb5-protos.h        mixer.h        pcap.h            security             term.h
asn1-common.h       devctl.h         getopt.h           krb5-types.h         monetary.h     pcap-namedb.h     _semaphore.h         termios.h
asn1_err.h          devdctl          glob.h             kvm.h                mp.h           pcap-netmap.h     semaphore.h          tgmath.h
assert.h            devinfo.h        grp.h              kx509_asn1.h         mpool.h        pkcs10_asn1.h     setjmp.h             threads.h
atf-c               devstat.h        gssapi             langinfo.h           mqueue.h       pkcs12_asn1.h     sha224.h             timeconv.h
atf-c++             dialog.h         gssapi.h           lib80211             mtlib.h        pkcs8_asn1.h      sha256.h             time.h
atf-c.h             digest_asn1.h    hdb_asn1.h         lib9p                ncurses_dll.h  pkcs9_asn1.h      sha384.h             timers.h
atf-c++.hpp         dirent.h         hdb_err.h          libcasper.h          ncurses.h      pkinit_asn1.h     sha512.h             ttyent.h
base64.h            dlfcn.h          hdb.h              libcasper_service.h  ndbm.h         pmcformat.h       sha512t.h            uchar.h
bitstring.h         dlg_colors.h     hdb-protos.h       libdwarf.h           net            pmc.h             sha.h                ucontext.h
blacklist.h         dlg_config.h     heim_asn1.h        libelf.h             net80211       pmclog.h          signal.h             ufs
Block.h             dlg_keys.h       heimbase.h         libgen.h             netconfig.h    poll.h            skein_freebsd.h      ugidfw.h
Block_private.h     dpv.h            heim_err.h         libgeom.h            netdb.h        printf.h          skein.h              ulimit.h
bluetooth.h         dwarf.h          heimntlm.h         libgpio.h            netgraph       private           skein_iv.h           ulog.h
bsdxml_external.h   edit             heimntlm-protos.h  libipt               netgraph.h     proc_service.h    skein_port.h         unctrl.h
bsdxml.h            efivar-dp.h      heim_threads.h     libmilter            netinet        protocols         spawn.h              unistd.h
bsm                 efivar.h         hex.h              libproc.h            netinet6       pthread.h         stab.h               usb.h
bsnmp               elf.h            histedit.h         libprocstat.h        netipsec       pthread_np.h      statcounters.h       usbhid.h
bzlib.h             elf-hints.h      hx509_err.h        librss.h             netnatm        pwd.h             statcounters_md.h    utempter.h
c++                 err.h            hx509.h            libufs.h             netpfil        radlib.h          statcounters_md.inc  utime.h
calendar.h          errno.h          hx509-private.h    libusb20_desc.h      netsmb         radlib_vs.h       stdalign.h           utmpx.h
cam                 eti.h            hx509-protos.h     libusb20.h           nfs            ranlib.h          stdarg.h             uuid.h
camlib.h            execinfo.h       iconv.h            libusb.h             nfsclient      rdma              stdatomic.h          varargs.h
capsicum_helpers.h  fcntl.h          ieeefp.h           libutil.h            nfsserver      readpassphrase.h  stdbool.h            vis.h
casper              fenv.h           ifaddrs.h          libxo                nlist.h        regex.h           stddef.h             vm
cheri               fetch.h          infiniband         limits.h             nl_types.h     resolve.h         stdint.h             wchar.h
cms_asn1.h          figpar.h         inttypes.h         linker_set.h         nss.h          resolv.h          stdio.h              wctype.h
com_err.h           filecomplete.h   iso646.h           link.h               nsswitch.h     res_update.h      stdlib.h             wind_err.h
compat              FlexLexer.h      isofs              locale.h             ntlm_err.h     rfc2459_asn1.h    stdnoreturn.h        wind.h
complex.h           float.h          jail.h             login_cap.h          ocsp_asn1.h    ripemd.h          string.h             wordexp.h
com_right.h         floatingpoint.h  k524_err.h         lzma                 opencsd        roken-common.h    stringlist.h         xdbm.h
cpio.h              fmtmsg.h         kadm5              lzma.h               openssl        roken.h           string_m.h           xlocale
crmf_asn1.h         fmtutils.h       kafs.h             machine              opie.h         rpc               strings.h            xlocale.h
crypto              fnmatch.h        kdc.h              magic.h              osreldate.h    rpcsvc            sys                  ypclnt.h
_ctype.h            form.h           kdc-protos.h       malloc.h             panel.h        rpoll.h           sysdecode.h          zconf.h
ctype.h             fs               kenv.h             malloc_np.h          parse_bytes

Upon running the clang commands with the -v flag, it showed the following:

ignoring nonexistent directory "~/cheri/output/rootfs-riscv64-purecap/usr/include"

This folder does exist and does contain all the headers.

How do I resolve this error?

1 Answer 1

2

ignoring nonexistent directory "~/cheri/output/rootfs-riscv64-purecap/usr/include"

Ah, there's an unexpanded ~ in there. Converting ~ to /home/username is a shell functionality, and you can't expect ~ to work anywhere else. Replace ~ by /home/yourusername in your aliases.

2
  • Thanks for responding. I made the change but I'm still facing a similar issue "ignoring nonexistent directory "/cheri/output/rootfs-riscv64-purecap/usr/include" Commented Mar 6, 2022 at 11:54
  • 1
    that is not the right, full path. It misses the /home/yourusername component. Commented Mar 6, 2022 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .