Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md does not document expat requirement on Ubuntu #304

Open
yunji-yunji opened this issue Sep 29, 2022 · 12 comments
Open

README.md does not document expat requirement on Ubuntu #304

yunji-yunji opened this issue Sep 29, 2022 · 12 comments

Comments

@yunji-yunji
Copy link

yunji-yunji commented Sep 29, 2022

I followed the insructions in ReadMe but I'm stuck in "run" command.
Googling couldn't solve my problem..


Question
Why Run command failed? Is this because I skipped build GDB?
I cannot get any useful information about my error on Google.
FYI, the error message is like below.
image


Environetment

  • OS: Ubuntu 22.04 LTS
  • Processor: 11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz × 8

What I did

  1. ./cheribuild.py qemu
  2. ./cheribuild.py llvm
  3. ./cheribuild.py cheribsd-riscv64-purecap
  4. ./cheribuild.py disk-image-riscv64-purecap
  5. tried to build gdb but failed. (I think GDB is optional so skip this step.)
  6. ./cheribuild.py run-riscv64-purecap --> Failed
  7. ./cheribuild.py sdk-riscv64-purecap --> Also Failed
@jrtc27
Copy link
Member

jrtc27 commented Sep 29, 2022

Since you decided to build all the dependencies manually (without -d/--include-dependencies) so you could skip gdb, you missed out the RISC-V firmware one, bbl-baremetal-riscv64-purecap (cheribuild --print-targets -d run-riscv64-purecap to get the full list of targets that would be run by -d).

The GDB failure is more interesting, though. What error do you get? That's supposed to work, but it's possible the updated system packages in 22.04 break it.

@yunji-yunji
Copy link
Author

I tried as follow. but all of them were failed.

Trial 1) ./cheribuild.py gdb-risc64-purecap

image

Trial 2) ./cheribuild.py gdb-risc64
image

Trial 3) ./cheribuild.py gdb-native
image

@yunji-yunji
Copy link
Author

Thank you for the solution, though!

@jrtc27
Copy link
Member

jrtc27 commented Sep 29, 2022

I tried as follow. but all of them were failed.

Trial 1) ./cheribuild.py gdb-risc64-purecap

image

This failed because there is no purecap version of GDB (purecap CheriBSD builds use a hybrid build of GDB).

Trial 2) ./cheribuild.py gdb-risc64 image

This failed because building GDB for a given architecture requires an existing CheriBSD build for that architecture, same as building any other program, you need the system headers and libraries.

Trial 3) ./cheribuild.py gdb-native image

As the error message says, this failed because you don't have expat installed. I guess older versions of Ubuntu implicitly pulled it in with the list of dependencies documented in our README but it no longer is (libexpat is, but expat the program isn't). Install expat and it should work.

However, gdb-native is not what you want; that's for building a GDB that runs natively on your x86 Ubuntu system, not inside CheriBSD. What you want is gdb-riscv64-hybrid-for-purecap-rootfs, which is what it says it is, a build of GDB that is itself a hybrid 64-bit RISC-V binary, but will be installed in your purecap rootfs, and thus disk image. Presumably that is also failing at the moment due to not having expat installed.

@jrtc27 jrtc27 changed the title "cheribuild.py run" doesn't work in Ubuntu 22.04 README.md does not document expat requirement on Ubuntu Sep 29, 2022
@yunji-yunji
Copy link
Author

I installed expat and it works well! I appreciate your kind explanation!

@yunji-yunji
Copy link
Author

I installed expat and libexpat, so building gdb-riscv64-hybrid-for-purecap-rootfs works but building sdk still doesn't work.
I think the root cause is from gdb-native part, but I have no idea about how to fix it.


What I did (in order)

sudo apt-get -y install expat
sudo apt-get -y install libexpat-ocaml-dev
./cheribuild.py gdb-riscv64-hybrid-for-purecap-rootfs      -> Sucess
./cheribuild.py sdk-riscv64-purecap                        -> Fail

Trial 1: ./cheribuild.py sdk-riscv64-purecap
image

Trial 2: ./cheribuild.py gdb-native

  • Trial 1 stopped at gdb-native part, so I tried this. But it failed even though I installed expat and libexpat.

image

@jrtc27
Copy link
Member

jrtc27 commented Sep 30, 2022

The sdk targets aren't particularly useful, but they shouldn't fail like that. Does cheribuild --clean gdb-native fare any better, in case there's something leftover from earlier attempts that break it?

@yunji-yunji
Copy link
Author

cheribuild --clean gdb-native failed with exactly same error message.
I think there is something leftover but I don't know what it is. So, in this case, how can I clean up the process?

image

@yunji-yunji
Copy link
Author

I need to build sdk to see assembly code, using /cheri/output/sdk/bin/clang -S test.c command.

I completely removed cheri/build/ folder, which includes gdb folder, and tried ./cheribuild.py sdk-riscv64-purecap command.
But, the same error occured and cheri/build/gdb-native-build folder was created again.
(This happened even with --no-run-under-gdb option.)

I need gdb to check assembly, but I don't need gdb-native.
I think the sdk command automatically links gdb-native folder.
How can I fix the error "Please include config.h first."?

@jrtc27
Copy link
Member

jrtc27 commented Oct 4, 2022

I don't know, I'd need to try and reproduce it.

Contrary to what you might think, the sdk target itself doesn't really do anything other than depend on the various components of a full SDK. The llvm target will build Clang (and install it in the sdk directory), and the cheribsd-riscv64-purecap target will build a sysroot with the headers and libraries you need to build riscv64-purecap software (and itself depends on llvm in order to do that).

Note you do need compiler flags to Clang to tell it that you want to build pure-capability CHERI-RISC-V binaries and where your CheriBSD sysroot is: -target riscv64-unknown-freebsd14 --sysroot=$HOME/cheri/output/rootfs-riscv64-purecap -B$HOME/cheri/output/sdk/bin -march=rv64imafdcxcheri -mabi=l64pc128d -mno-relax. There's ~/cheri/output/sdk/utils/cheribsd-riscv64-purecap-clang as a convenient utility you can use, though it's intended for humans to use, not something that build scripts should rely on.

@jrtc27
Copy link
Member

jrtc27 commented Oct 7, 2022

Ok, the gdb-native issue is https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=aebc4aa2ece0363c16cab5a546df05220227ec31, current CHERI GDB is on an old enough branch that it doesn't have that fix for newer glibc. I've backported the fix and, at least for me, gdb-native now builds on Ubuntu 22.04.

@yunji-yunji
Copy link
Author

Thank you so much for your help!

Now, both the comilation and gdb-native work well for me. Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants