gitgit-submodulesubuntu-20.04riscv

Error Fetching Submodule in RISC-V GNU Toolchain: Server Does Not Allow Request for Unadvertised Object


OS:Ubuntu20.04LTS

Description:

I followed the instructions in the riscv-gnu-toolchain README. First, I ran:

git clone https://github.com/riscv/riscv-gnu-toolchain

I installed the required dependencies with:

sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev

executed the following commands to configure and build:

./configure --prefix=/opt/riscv
make

results are

make
cd /home/fufu/gits/riscv-gnu-toolchain && \
flock `git rev-parse --git-dir`/config git submodule init /home/fufu/gits/riscv-gnu-toolchain/newlib/ && \
flock `git rev-parse --git-dir`/config git submodule update --progress --depth 1 /home/fufu/gits/riscv-gnu-toolchain/newlib/
Submodule 'newlib' (https://sourceware.org/git/newlib-cygwin.git) registered for path 'newlib'
Cloning into '/home/fufu/gits/riscv-gnu-toolchain/newlib'...
remote: Enumerating objects: 6971, done.        
remote: Counting objects: 100% (6971/6971), done.        
remote: Compressing objects: 100% (5327/5327), done.        
remote: Total 6971 (delta 2582), reused 3275 (delta 1516), pack-reused 0        
Receiving objects: 100% (6971/6971), 14.31 MiB | 3.46 MiB/s, done.
Resolving deltas: 100% (2582/2582), done.
remote: Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
error: Server does not allow request for unadvertised object 26f7004bf73c421c3fd5e5a6ccf470d05337b435
Fetched in submodule path 'newlib', but it did not contain 26f7004bf73c421c3fd5e5a6ccf470d05337b435. Direct fetching of that commit failed.
make: *** [Makefile:348: /home/fufu/gits/riscv-gnu-toolchain/newlib/.git] Error 1

What I Tried:

follow gpt

cd newlib
git checkout master
git pull origin master
git submodule update --init --recursive

the error became

Cloning into '/home/fufu/gits/riscv-gnu-toolchain/spike'...
Cloning into '/home/fufu/gits/riscv-gnu-toolchain/uclibc-ng'...
error: Server does not allow request for unadvertised object beb2cdbcda911764b2bed5e57921fe90493260bd
Fetched in submodule path 'binutils', but it did not contain beb2cdbcda911764b2bed5e57921fe90493260bd. Direct fetching of that commit failed.

And I do it again in binutils but still

error: Server does not allow request for unadvertised object beb2cdbcda911764b2bed5e57921fe90493260bd
Fetched in submodule path 'binutils', but it did not contain beb2cdbcda911764b2bed5e57921fe90493260bd. Direct fetching of that commit failed.

I try

git submodule sync 
git submodule update --init --recursive

with the same problem

My Questions: What caused the error: "Server does not allow request for unadvertised object"? How can I resolve this issue? Thank you very much for your help!


Solution

  • error: Server does not allow request for unadvertised object 26f7004bf73c421c3fd5e5a6ccf470d05337b435
    Fetched in submodule path 'newlib', but it did not contain 26f7004bf73c421c3fd5e5a6ccf470d05337b435. Direct fetching of that commit failed.
    

    This error happens when Git fetches a commit directly by its hash, i.e. it did git fetch origin 26f7004bf73c421c3fd5e5a6ccf470d05337b435, and the server (here https://sourceware.org/git/newlib-cygwin.git) does not allow to fetch objects directly by their hashes. The server does not allow these fetches because the communication is using the Git protocol v0 and the configs uploadpack.allowTipSHA1InWant, uploadpack.allowReachableSHA1InWant and uploadpack.allowAnySHA1InWant are all false (their default values) on https://sourceware.org.

    The reason Git fetches a commit directly by its hash is that git submodule update first tries a simple git fetch, and if the commit recorded in the superproject is not available after that fetch (because it is not reachable from the branches that were fetched) then it fetches it directly, which is what happens here.

    On Ubuntu 20.04, the Git version is 2.25.1, and this version still defaults to protocol v0, which is why you get the above error. On Ubuntu 22.04, the Git version is 2.34.1, in which the default protocol version is v2 (it is the default since Git 2.26.0), and the configs mentioned above have no effect when using protocol v2: fetching by hash is always permitted. This explains why it works on Ubuntu 22.

    Note that protocol v2 is implemented since Git 2.18.0, so even on Ubuntu 20 you could make it work by asking Git to use it: git config --global protocol.version 2.

    Note also that for it to work, the server must also be recent enough to default to protocol v2, which is the case on sourceware.org since it is using Git 2.43.5, which you can see by doing :

     GIT_TRACE_BARE=1 GIT_TRACE_PACKET=1 git -c protocol.version=2 ls-remote --heads https://sourceware.org/git/newlib-cygwin.git 2>&1 | head