lwthiker / curl-impersonate

curl-impersonate: A special build of curl that can impersonate Chrome & Firefox
MIT License
3.45k stars 229 forks source link

Compilation Errors on FreeBSD #145

Open open-trap opened 1 year ago

open-trap commented 1 year ago

Problem description

gmake fails during boringssl's handshaker.cc test with declaration scope errors and unused function errors.

What changes are required to compile on FreeBSD? The Linux curl-impersonate binary works on FreeBSD using the Linux compatibility layer, but can't be linked to when installing Python packages with pip (FreeBSD ld can't "find" curl-impersonate-chrome.so to link to because it's the wrong ELF).

Build environment inside clean 13.1-RELEASE jail

root:~ # pkg install pkgconf curl cmake gcc unzip go ninja gmake bash perl5.35
root:~ # setenv CC /usr/local/bin/gcc; setenv CXX /usr/local/bin/g++

Error messages

[18/26] Building CXX object ssl/test/CMakeFiles/handshaker.dir/handshaker.cc.o
FAILED: ssl/test/CMakeFiles/handshaker.dir/handshaker.cc.o
/usr/local/bin/g++ -DBORINGSSL_IMPLEMENTATION -I/root/curl-impersonate/build/boringssl/third_party/googletest/include -I/root/curl-impersonate/build/boringssl/ssl/test/../../include -Werror -Wformat=2 -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -Wvla -Wshadow -ggdb -Wall -fvisibility=hidden -fno-common -Wno-free-nonheap-object -Wimplicit-fallthrough -Wmissing-declarations -std=c++11 -fno-exceptions -fno-rtti -O3 -DNDEBUG -fPIE -MD -MT ssl/test/CMakeFiles/handshaker.dir/handshaker.cc.o -MF ssl/test/CMakeFiles/handshaker.dir/handshaker.cc.o.d -o ssl/test/CMakeFiles/handshaker.dir/handshaker.cc.o -c /root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc: In function 'bool {anonymous}::Handshaker(const TestConfig*, int, int, bssl::Span<const unsigned char>, int)':
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:96:18: error: 'kControlMsgWantRead' was not declared in this scope
   96 |       char msg = kControlMsgWantRead;
      |                  ^~~~~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:99:18: error: 'kControlMsgWriteCompleted' was not declared in this scope
   99 |           msg != kControlMsgWriteCompleted) {
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:127:14: error: 'kControlMsgDone' was not declared in this scope
  127 |   char msg = kControlMsgDone;
      |              ^~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc: In function 'bool {anonymous}::GenerateHandshakeHint(const TestConfig*, bssl::Span<const unsigned char>, int)':
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:191:16: error: 'kControlMsgError' was not declared in this scope
  191 |     char msg = kControlMsgError;
      |                ^~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:205:14: error: 'kControlMsgDone' was not declared in this scope
  205 |   char msg = kControlMsgDone;
      |              ^~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc: In function 'int {anonymous}::SignalError()':
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:216:20: error: 'kControlMsgError' was not declared in this scope
  216 |   const char msg = kControlMsgError;
      |                    ^~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:217:19: error: 'kFdControl' was not declared in this scope
  217 |   if (write_eintr(kFdControl, &msg, 1) != 1) {
      |                   ^~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc: In function 'int main(int, char**)':
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:248:28: error: 'kFdControl' was not declared in this scope
  248 |   ssize_t len = read_eintr(kFdControl, request.data(), request.size());
      |                            ^~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:260:29: error: 'kFdProxyToHandshaker' was not declared in this scope
  260 |     if (!Handshaker(config, kFdProxyToHandshaker, kFdHandshakerToProxy,
      |                             ^~~~~~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:260:51: error: 'kFdHandshakerToProxy' was not declared in this scope
  260 |     if (!Handshaker(config, kFdProxyToHandshaker, kFdHandshakerToProxy,
      |                                                   ^~~~~~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc: At global scope:
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:137:6: error: 'bool {anonymous}::GenerateHandshakeHint(const TestConfig*, bssl::Span<const unsigned char>, int)' defined but not used [-Werror=unused-function]
  137 | bool GenerateHandshakeHint(const TestConfig *config,
      |      ^~~~~~~~~~~~~~~~~~~~~
/root/curl-impersonate/build/boringssl/ssl/test/handshaker.cc:55:6: error: 'bool {anonymous}::Handshaker(const TestConfig*, int, int, bssl::Span<const unsigned char>, int)' defined but not  used [-Werror=unused-function]
   55 | bool Handshaker(const TestConfig *config, int rfd, int wfd,
      |      ^~~~~~~~~~
cc1plus: all warnings being treated as errors
[24/26] Building CXX object decrepit/CMakeFiles/decrepit_test.dir/xts/xts_test.cc.o
ninja: build stopped: subcommand failed.
gmake: *** [Makefile:267: /root/curl-impersonate/build/boringssl/build/lib/libssl.a] Error 1

Other details

root:~ # file -sL curl-impersonate/curl-impersonate-chrome
curl-impersonate/curl-impersonate-chrome: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=8cbd1933a3b32efaaad4d3e1dfc5dbfd337e86ab, for GNU/Linux 3.2.0, stripped

root:~ # ldd curl-impersonate/curl-impersonate-chrome
curl-impersonate/curl-impersonate-chrome:
        linux_vdso.so.1 (0x00007ffffffff000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x0000000801352000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x000000080136e000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000000801391000)
        /lib64/ld-linux-x86-64.so.2 (0x0000000801318000)
lwthiker commented 4 months ago

I just tried building curl-impersonate on FreeBSD with the new boringssl version (#217). Unfortunately, it fails due to errors in upstream boringssl.

/root/curl-impersonate/build/boringssl/crypto/rand_extra/getentropy.c:38:9: error: implicit declaration of function 'getentropy'

I'll keep this issue open until upstream boringssl resolves this.