Build edk2 on Ubuntu20.04 - shijunjing/edk2 GitHub Wiki
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Problems
- Build failure 1
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ git clean -dfx
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ make -C BaseTools/
...
mrhoist.c: In function 'MR_ruleNamePlusOffset':
mrhoist.c:2220:37: warning: '__builtin___sprintf_chk' may write a terminating nul past the end of the destination [-Wformat-overflow=]
2220 | sprintf(ruleNameStatic2,"%s/%d",ruleNameStatic1,offset+1);
| ^
In file included from /usr/include/stdio.h:867,
from mrhoist.c:28:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:36:10: note: '__builtin___sprintf_chk' output between 3 and 61 bytes into a destination of size 60
36 | return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | __bos (__s), __fmt, __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Build failure 2
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ git clean -dfx
jshi19@ub2-uefi-b01:~/wksp_efi/edk2-2$ make -C BaseTools/
...
make -C BrotliCompress
make[2]: Entering directory '/home/jshi19/wksp_efi/edk2-2/BaseTools/Source/C/BrotliCompress'
make[2]: *** No rule to make target '/usr/include/x86_64-linux-gnu/bits/libio.h', needed by 'brotli/c/tools/brotli.o'. Stop.
...
make[2]: *** No rule to make target '/usr/include/x86_64-linux-gnu/bits/_G_config.h', needed by 'brotli/c/tools/brotli.o'. Stop.
...
make[2]: *** No rule to make target '/usr/include/x86_64-linux-gnu/bits/byteswap-16.h', needed by 'brotli/c/tools/brotli.o'. Stop.
Solution
Copy the below three libc6-dev header files from ubuntu18.04 to ubuntu20.04:
/usr/include/x86_64-linux-gnu/bits/libio.h
/usr/include/x86_64-linux-gnu/bits/_G_config.h
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h
- https://askubuntu.com/questions/1260661/libc6-dev-header-files-missing-on-ubuntu-20-04
- https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1888302/comments/3 "I just had to fetch libio.h and _G_config.h from an old Ubuntu 18.04 to compile a programme on 20.04."