nginx集成quiche编译及问题解决

1. 环境准备

quiche编译需要用到cargo,提前准备好

# curl https://sh.rustup.rs -sSf | sh

# source $HOME/.cargo/env

2. 下载nginx

# wget https://nginx.org/download/nginx-1.16.1.tar.gz

# git clone --recursive https://github.com/cloudflare/quiche

# cd nginx-1.16.1

# patch -p01 < ../quiche/extras/nginx/nginx-1.16.patch

# ./configure --without-http_gzip_module --without-http_rewrite_module --with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-openssl=../quiche/deps/boringssl --with-quiche=../quiche

# make

2.编译quiche examples

为了测试quic,需要用到quic client,在quiche中

# cargo build --examples

会遇到如下问题

/usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_pcia.c.o): relocation R_X86_64_32 against hidden symbol `PROXY_POLICY_it' can not be used when making a shared object
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_pcons.c.o): relocation R_X86_64_32 against hidden symbol `POLICY_CONSTRAINTS_it' can not be used when making a shared object
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_pku.c.o): relocation R_X86_64_32 against hidden symbol `PKEY_USAGE_PERIOD_it' can not be used when making a shared object
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_pmaps.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_prn.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_purp.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_skey.c.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_sxnet.c.o): relocation R_X86_64_32 against hidden symbol `SXNETID_it' can not be used when making a shared object
          /usr/bin/ld: /root/source/quiche/deps/boringssl/build//libcrypto.a(v3_utl.c.o): relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
          /usr/bin/ld: final link failed: Nonrepresentable section on output
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: could not compile `quiche`.

To learn more, run the command again with --verbose.

是因为编译boringssl时没有加"-fPIC"参数,修改nginx/obj/Makefile如下

../quiche/deps/boringssl/.openssl/include/openssl/ssl.h:        objs/Makefile
        mkdir -p ../quiche/deps/boringssl/build ../quiche/deps/boringssl/.openssl/lib ../quiche/deps/boringssl/.openssl/include/openssl \
        && cd ../quiche/deps/boringssl/build \
        && cmake -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" .. \
        && $(MAKE) VERBOSE=1 \
        && cd .. \
        && cp -r src/include/openssl/*.h .openssl/include/openssl \
        && cp build/libssl.a build/libcrypto.a .openssl/lib

重新编译nginx,再执行cargo build --examples

参考链接:

Nginx 体验HTTP/3.0 (Cloudflare补丁)

HTTP/3 初体验 - 云+社区 - 腾讯云

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值