musl-cross-make icon indicating copy to clipboard operation
musl-cross-make copied to clipboard

Is it possible to support gdb

Open elliott10 opened this issue 3 years ago • 4 comments

Is it possible to support gdb? GDB is very useful. Like: https://github.com/riscv-collab/riscv-binutils-gdb

elliott10 avatar Apr 28 '22 04:04 elliott10

I have compiled gdb this way:

git clone https://github.com/richfelker/musl-cross-make.git

cat >musl-cross-make/config.mak <<EOF
TARGET=i686-linux-musl
MUSL_VER=git-v1.2.2
GCC_VER=10.3.0
# Not needed libs
COMMON_CONFIG += --disable-nls
EOF

make --directory musl-cross-make -j$(nproc)
make --directory musl-cross-make install

mkdir gdb
wget https://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz --output-document -  \
| tar -xz --strip-components 1 --directory gdb
(cd gdb &&  \
 PATH=$PATH:$PWD/../musl-cross-make/output/bin   \
 ./configure  \
     --prefix=$PWD/output  \
     --host=i686-linux-musl  \
     --disable-nls  \
     --with-curses)

PATH=$PATH:$PWD/musl-cross-make/output/bin make --directory gdb -j$(nproc)
PATH=$PATH:$PWD/musl-cross-make/output/bin make --directory gdb install

Don't know if this answers your question.

jsommr avatar May 16 '22 12:05 jsommr

I have compiled gdb this way:

git clone https://github.com/richfelker/musl-cross-make.git

cat >musl-cross-make/config.mak <<EOF
TARGET=i686-linux-musl
MUSL_VER=git-v1.2.2
GCC_VER=10.3.0
# Not needed libs
COMMON_CONFIG += --disable-nls
EOF

make --directory musl-cross-make -j$(nproc)
make --directory musl-cross-make install

mkdir gdb
wget https://ftp.gnu.org/gnu/gdb/gdb-10.2.tar.gz --output-document -  \
| tar -xz --strip-components 1 --directory gdb
(cd gdb &&  \
 PATH=$PATH:$PWD/../musl-cross-make/output/bin   \
 ./configure  \
     --prefix=$PWD/output  \
     --host=i686-linux-musl  \
     --disable-nls  \
     --with-curses)

PATH=$PATH:$PWD/musl-cross-make/output/bin make --directory gdb -j$(nproc)
PATH=$PATH:$PWD/musl-cross-make/output/bin make --directory gdb install

Don't know if this answers your question.

Thank you ! It is very useful.

And I tried like this:

  • Firstly, Building out a specific arch(eg. riscv64) cross-compilation tool chain by richfelker/musl-cross-make
  • Secondly, Download gdb source file, and unzip the ziped file.
  • And then, Configure the gdb and build:
cd gdb-source-code
./configure --target=riscv64-linux-musl --prefix=$PWD/install
make
make install

elliott10 avatar May 22 '22 09:05 elliott10

The snippet in my answer is from a longer article. If you are still unable to get gdb working, perhaps the section on "Debugging" could be of interest to you: https://ja.nsommer.dk/articles/linux-and-tiny-c-compiler-in-the-browser-part-one.html

jsommr avatar May 22 '22 12:05 jsommr

The snippet in my answer is from a longer article. If you are still unable to get gdb working, perhaps the section on "Debugging" could be of interest to you: https://ja.nsommer.dk/articles/linux-and-tiny-c-compiler-in-the-browser-part-one.html

My homebrew cross-compiled gdb works well. Thank you for your article, nerfpops! Running Tiny C Compiler in browser is absolutely cool :)

elliott10 avatar May 22 '22 14:05 elliott10