sagernet / cronet-go Goto Github PK
View Code? Open in Web Editor NEWThe Chromium network stack library for Go
License: Other
The Chromium network stack library for Go
License: Other
该项目似乎在padding填充出现问题。
首先第一处:https://github.com/SagerNet/cronet-go/blob/main/naive/main.go#L223 会引发网页空白,通过调试代码发现的。
发现该BUG是我编译项目后发现,代理页面访问空白。wireshark抓包发现请求可以到达服务器,但服务器似乎无法相应。于是我对项目进行debug,最后找到"Padding": generatePaddingHeader(),
引起的,注释掉正常,但头部就没法填充了,作者能否找下原因所在?
第二处,代码的padding填充处理的无限递归问题,程序会突然崩溃!
https://github.com/SagerNet/cronet-go/blob/main/naive/main.go#L277-L282
无限递归处会引发程序崩溃,会出现Runtime: goroutine stack exceeds 1000000000-byte limit fatal error: stack overflow in ACM
溢出错误。并且填充后网页打开证书那些显示不安全,并且也是空白页面,可能填充逻辑需要改进。
作者能否修复下?
How can I solve this problem?
$ go run naive/main.go
# github.com/sagernet/cronet-go
/home/linuxbrew/.linuxbrew/bin/ld: unrecognised emulation mode: llvm
dont find DialContext or Proxy field.
thank for your work.
Lines 69 to 73 in b2643a8
-network-isolation-key
header.Can you add support for compiling for mac?
I am on the linux64 platform and installed the version of go 1.18.1, but there is a problem with the precompile
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/lib/clang/15.0.0/lib/x86_64-unknown-linux-gnu => llvm/lib/clang/15.0.0/lib/x86_64-cros-linux-gnu
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/clang => llvm/bin/clang++
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/llvm-readobj => llvm/bin/llvm-readelf
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/llvm-objcopy => llvm/bin/llvm-strip
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/clang => llvm/bin/clang-cl
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/ld.lld
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/ld64.lld
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/lld-link
INFO[0011] [prebuild]: >> /root/cronet-go/llvm/bin/lld => llvm/bin/wasm-ld
FATA[0011] [prebuild]: linux-x64 release not found in https://api.github.com/repos/klzgrad/naiveproxy/releases/67460277/assets
I just saw that you have an update, but it seems that there are still some problems on openwrt, such as the problem that it can easily cause the exit
goroutine 284 [select]:
github.com/sagernet/cronet-go.(*BidirectionalConn).Read(0x400008e9c0, {0x40003e8400, 0x3, 0x7c00})
/root/cronet-go/bidirectional_conn.go:72 +0xac
io.ReadAtLeast({0x7f8ef91d18, 0x400008e9c0}, {0x40003e8400, 0x3, 0x7c00}, 0x3)
/usr/local/go/src/io/io.go:331 +0xa4
io.ReadFull(...)
/usr/local/go/src/io/io.go:350
main.(*PaddingConn).Read(0x400009ae10, {0x40003e8400, 0x7c00, 0x7c00})
/root/cronet-go/naive/main.go:297 +0x12c
github.com/sagernet/sing/common/bufio.(*ExtendedReaderWrapper).ReadBuffer(0x7fb5edb108?, 0x400009af30)
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:430 +0x5c
github.com/sagernet/sing/common/bufio.CopyExtendedBuffer({0x5563ed9fd8, 0x400020e7b0}, {0x5563ed9fb0, 0x400020e7c0}, 0x400009af30)
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:74 +0xf0
github.com/sagernet/sing/common/bufio.CopyExtended({0x5563ed9fd8?, 0x400020e7b0}, {0x5563ed9fb0?, 0x400020e7c0})
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:66 +0x18c
github.com/sagernet/sing/common/bufio.Copy({0x5563ed9240, 0x400020e7a0}, {0x7f8ef902f8?, 0x400009ae10?})
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:51 +0x270
github.com/sagernet/sing/common/bufio.(*readOnlyReader).WriteTo(0x4000042538?, {0x5563ed9240?, 0x400020e7a0?})
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:23 +0x3c
io.copyBuffer({0x5563ed9240, 0x400020e7a0}, {0x5563ed8780, 0x400020e790}, {0x0, 0x0, 0x0})
/usr/local/go/src/io/io.go:408 +0x128
io.Copy(...)
/usr/local/go/src/io/io.go:385
net.genericReadFrom({0x5563ed8a00?, 0x400021e078?}, {0x5563ed8780, 0x400020e790})
/usr/local/go/src/net/net.go:662 +0x6c
net.(*TCPConn).readFrom(0x400021e078, {0x5563ed8780, 0x400020e790})
/usr/local/go/src/net/tcpsock_posix.go:54 +0x74
net.(*TCPConn).ReadFrom(0x400021e078, {0x5563ed8780?, 0x400020e790?})
/usr/local/go/src/net/tcpsock.go:130 +0x34
github.com/sagernet/sing/common/bufio.Copy({0x5563ed8a00, 0x400021e078}, {0x7f8ef902f8?, 0x400009ae10?})
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:49 +0x188
github.com/sagernet/sing/common/bufio.CopyConn.func2()
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/bufio/conn.go:131 +0xf4
github.com/sagernet/sing/common/task.Run.func1()
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/task/task.go:18 +0x48
created by github.com/sagernet/sing/common/task.Run
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/task/task.go:17 +0xf4
goroutine 178 [IO wait]:
internal/poll.runtime_pollWait(0x7f8f1614a8, 0x72)
/usr/local/go/src/runtime/netpoll.go:302 +0xa4
internal/poll.(*pollDesc).wait(0x400021c780?, 0x40001aa549?, 0x0)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:83 +0x2c
internal/poll.(*pollDesc).waitRead(...)
/usr/local/go/src/internal/poll/fd_poll_runtime.go:88
internal/poll.(*FD).Read(0x400021c780, {0x40001aa549, 0x1, 0x1})
/usr/local/go/src/internal/poll/fd_unix.go:167 +0x1e4
net.(*netFD).Read(0x400021c780, {0x40001aa549?, 0x40001f75e8?, 0x5563b55844?})
/usr/local/go/src/net/fd_posix.go:55 +0x2c
net.(*conn).Read(0x400021e0c8, {0x40001aa549?, 0x40001f7618?, 0x5563db15d8?})
/usr/local/go/src/net/net.go:183 +0x38
io.ReadAtLeast({0x5563ed89c0, 0x400021e0c8}, {0x40001aa549, 0x1, 0x1}, 0x1)
/usr/local/go/src/io/io.go:331 +0xa4
io.ReadFull(...)
/usr/local/go/src/io/io.go:350
github.com/sagernet/sing/common/rw.ReadByte({0x5563ed89c0, 0x400021e0c8})
/root/go/pkg/mod/github.com/sagernet/[email protected]/common/rw/read.go:22 +0x68
github.com/sagernet/sing/protocol/socks/socks4.readString({0x5563ed89c0, 0x400021e0c8})
/root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/socks4/protocol.go:160 +0x4c
github.com/sagernet/sing/protocol/socks/socks4.ReadRequest0({0x5563ed89c0, 0x400021e0c8})
/root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/socks4/protocol.go:67 +0x184
github.com/sagernet/sing/protocol/socks.HandleConnection0({0x5563edb730?, 0x4000024080}, {0x5563edcc28?, 0x400021e0c8}, 0xe8?, {0x0?, 0x0?}, {0x7f8ef90028?, 0x40001010b0}, {{0x5563a95220, ...}, ...})
/root/go/pkg/mod/github.com/sagernet/[email protected]/protocol/socks/handshake.go:108 +0x10c
github.com/sagernet/sing/transport/mixed.(*Listener).NewConnection(0x4000020230, {0x5563edb730, 0x4000024080}, {0x5563edcc28, 0x400021e0c8?}, {{0x5563a95220, 0x3}, {{{0x0, 0xffffc0a81ffe}, 0x400000e030}, ...}, ...})
/root/go/pkg/mod/github.com/sagernet/[email protected]/transport/mixed/listener.go:65 +0x998
github.com/sagernet/sing/transport/tcp.(*Listener).loop.func1()
/root/go/pkg/mod/github.com/sagernet/[email protected]/transport/tcp/listener.go:97 +0xa8
created by github.com/sagernet/sing/transport/tcp.(*Listener).loop
/root/go/pkg/mod/github.com/sagernet/[email protected]/transport/tcp/listener.go:95 +0x30
Sorry not familiar with c/c++.
When do I need to call destroy() for a cronet-created structure (like RequestFinishedInfo), or not? And what about incoming parameters like HttpHeader?
I can do chunked body http request with net/http.Client,
my server.go can process the received chunk one by one:
$ go run server.go
2024/05/16 17:06:50 Starting server on port 1081...
2024/05/16 17:06:53 received: aaaaaaaaaaaaaa
2024/05/16 17:06:56 received: bbbbbbbbbbbbbb
but if I enable cronet by uncommenting this line of "Transport: &cronet.RoundTripper{}" in my client.go, it will block there forever,
I can't figure out how to do chunked body request with cronet-go,
any hint?
my server.go:
package main
import (
"bufio"
"encoding/base64"
"fmt"
"io"
"log"
"net"
"net/http"
)
const (
udpIP = "127.0.0.1"
udpPort = 1082
)
func handlePost(w http.ResponseWriter, r *http.Request) {
var data []byte
reader := bufio.NewReader(r.Body)
for {
chunkSizeStr, err := reader.ReadString('\n')
if err != nil {
if err == io.EOF {
break
}
log.Printf("Error reading chunk size: %v", err)
http.Error(w, "Error reading chunk size", http.StatusInternalServerError)
return
}
var chunkSize int
if _, err := fmt.Sscanf(chunkSizeStr, "%x", &chunkSize); err != nil {
log.Printf("Invalid chunk size: %v", err)
http.Error(w, "Invalid chunk size", http.StatusBadRequest)
return
}
if chunkSize == 0 {
break
}
chunk := make([]byte, chunkSize)
if _, err := io.ReadFull(reader, chunk); err != nil {
log.Printf("Error reading chunk data: %v", err)
http.Error(w, "Error reading chunk data", http.StatusInternalServerError)
return
}
if _, err := reader.Discard(2); err != nil { // Discard the trailing "\r\n"
log.Printf("Error discarding CRLF: %v", err)
http.Error(w, "Error discarding CRLF", http.StatusInternalServerError)
return
}
decodedChunk, err := base64.StdEncoding.DecodeString(string(chunk))
if err != nil {
log.Printf("Base64 decoding error: %v", err)
continue
}
data = append(data, decodedChunk...)
log.Println("received: "+string(decodedChunk))
}
udpAddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", udpIP, udpPort))
if err != nil {
log.Printf("Error resolving UDP address: %v", err)
return
}
conn, err := net.DialUDP("udp", nil, udpAddr)
if err != nil {
log.Printf("Error dialing UDP: %v", err)
return
}
defer conn.Close()
_, err = conn.Write(data)
if err != nil {
log.Printf("Error sending UDP data: %v", err)
return
}
w.Write([]byte("POST request processed"))
}
func main() {
http.HandleFunc("/", handlePost)
log.Println("Starting server on port 1081...")
err := http.ListenAndServe(":1081", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
}
my client.go:
package main
import (
"fmt"
"io"
"log"
"net/http"
"strconv"
"time"
//"github.com/SagerNet/cronet-go"
)
type ChunkedReader struct {
chunks [][]byte
delay time.Duration
index int
}
func (r *ChunkedReader) Read(p []byte) (n int, err error) {
log.Printf("Entering read function, current index: %d", r.index)
if r.index >= len(r.chunks) {
return 0, io.EOF
}
if r.index > 0 {
time.Sleep(r.delay)
}
chunk := r.chunks[r.index]
n = copy(p, chunk)
log.Printf("Copied chunk %d, length: %d", r.index, n)
r.index++
return n, nil
}
func formatChunk(data []byte) []byte {
size := strconv.FormatInt(int64(len(data)), 16)
return []byte(fmt.Sprintf("%s\r\n%s\r\n", size, data))
}
func main() {
client := &http.Client{
//Transport: &cronet.RoundTripper{},
}
data1 := []byte("YWFhYWFhYWFhYWFhYWE=")
data2 := []byte("YmJiYmJiYmJiYmJiYmI=")
chunk1 := formatChunk(data1)
chunk2 := formatChunk(data2)
finalChunk := []byte("0\r\n\r\n")
chunkedReader := &ChunkedReader{
chunks: [][]byte{chunk1, chunk2, finalChunk},
delay: 3 * time.Second,
}
headers := map[string]string{
"Host": "127.0.0.1",
"Content-Type": "application/octet-stream",
"Transfer-Encoding": "chunked",
}
req, err := http.NewRequest("POST", "http://127.0.0.1:1081", chunkedReader)
if err != nil {
log.Fatalf("Failed to create request: %v", err)
}
req.Proto = "HTTP/1.1"
req.ProtoMajor = 1
req.ProtoMinor = 1
for key, value := range headers {
req.Header.Set(key, value)
}
log.Print("Before client.Do")
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Request failed: %v", err)
}
defer func() {
if cerr := resp.Body.Close(); cerr != nil {
log.Printf("Failed to close response body: %v", cerr)
}
}()
log.Print("Waiting for request to complete...")
fmt.Printf("Response status: %s\n", resp.Status)
}
Run at Linux docker image golang:1.18.3
cmd/build/a.go
package main
import (
"github.com/sagernet/cronet-go"
"net/http"
"os"
)
func main() {
client := &http.Client{
Transport: &cronet.RoundTripper{
CheckRedirect: func(newLocationUrl string) bool {
return false
},
},
}
response, _ := client.Get("https://httpbin.org/status/302")
response.Write(os.Stderr)
response.Body.Close()
}
Error stack after running:
root@80b5520f4a27:/code/cronet-go#
root@80b5520f4a27:/code/cronet-go#
root@80b5520f4a27:/code/cronet-go# ./main cmd/build/a.go
HOSTNAME=80b5520f4a27
PWD=/code/cronet-go
HOME=/root
GOLANG_VERSION=1.18.3
TERM=xterm
SHLVL=1
PATH=/code/cronet-go/llvm/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
GOPATH=/go
OLDPWD=/go
_=./main
CGO_LDFLAGS=-pie -I /code/cronet-go --sysroot=/code/cronet-go/sysroot -fuse-ld=lld -m64
CGO_CFLAGS=-I /code/cronet-go --sysroot=/code/cronet-go/sysroot -m64 -march=x86-64 -msse3
CC=clang
CGO_ENABLED=1
CGO_LDFLAGS_ALLOW=.*
root@80b5520f4a27:/code/cronet-go#
root@80b5520f4a27:/code/cronet-go#
root@80b5520f4a27:/code/cronet-go# ./a
SIGTRAP: trace trap
PC=0x7f2f61201f03 m=5 sigcode=128
signal arrived during cgo execution
goroutine 1 [syscall]:
runtime.cgocall(0x55641c3e1740, 0xc000119a88)
/usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc000119a60 sp=0xc000119a28 pc=0x55641c1c25dc
github.com/sagernet/cronet-go._Cfunc_Cronet_UrlRequest_Read(0x16c8002382a0, 0x16c80023e070)
_cgo_gotypes.go:2553 +0x50 fp=0xc000119a88 sp=0xc000119a60 pc=0x55641c3d8810
github.com/sagernet/cronet-go.URLRequest.Read.func1({0xc000119af0?}, {0xc000119ae8?})
/code/cronet-go/url_request.go:73 +0x70 fp=0xc000119ac8 sp=0xc000119a88 pc=0x55641c3dc490
github.com/sagernet/cronet-go.URLRequest.Read({0x0?}, {0xc000152000?})
/code/cronet-go/url_request.go:73 +0x19 fp=0xc000119ae8 sp=0xc000119ac8 pc=0x55641c3dc3d9
github.com/sagernet/cronet-go.(*urlResponse).Read(0xc00014c000, {0xc000152000, 0x800, 0x2000})
/code/cronet-go/transport.go:184 +0x128 fp=0xc000119b78 sp=0xc000119ae8 pc=0x55641c3d5588
io.(*LimitedReader).Read(0xc00000e138, {0xc000152000?, 0x1d?, 0xc000119c70?})
/usr/local/go/src/io/io.go:476 +0x45 fp=0xc000119ba8 sp=0xc000119b78 pc=0x55641c240ea5
io.discard.ReadFrom({}, {0x55641c44a768, 0xc00000e138})
/usr/local/go/src/io/io.go:610 +0x72 fp=0xc000119c00 sp=0xc000119ba8 pc=0x55641c241072
io.(*discard).ReadFrom(0x641c4073e0?, {0x55641c44a768?, 0xc00000e138?})
<autogenerated>:1 +0x37 fp=0xc000119c20 sp=0xc000119c00 pc=0x55641c241757
io.copyBuffer({0x55641c44af08, 0x55641c5e7700}, {0x55641c44a768, 0xc00000e138}, {0x0, 0x0, 0x0})
/usr/local/go/src/io/io.go:412 +0x14b fp=0xc000119ca0 sp=0xc000119c20 pc=0x55641c240c8b
io.Copy(...)
/usr/local/go/src/io/io.go:385
io.CopyN({0x55641c44af08, 0x55641c5e7700}, {0x7f2f376cb848?, 0xc00014c000}, 0x800)
/usr/local/go/src/io/io.go:361 +0x9a fp=0xc000119cf0 sp=0xc000119ca0 pc=0x55641c240aba
net/http.(*Client).do(0xc00006edb0, 0xc00014a100)
/usr/local/go/src/net/http/client.go:707 +0x81d fp=0xc000119ef0 sp=0xc000119cf0 pc=0x55641c39559d
net/http.(*Client).Do(...)
/usr/local/go/src/net/http/client.go:593
net/http.(*Client).Get(0x55641c3e2f10?, {0x55641c14f29c?, 0x0?})
/usr/local/go/src/net/http/client.go:480 +0x6a fp=0xc000119f48 sp=0xc000119ef0 pc=0x55641c394aea
main.main()
/code/cronet-go/cmd/build/a.go:18 +0x85 fp=0xc000119f80 sp=0xc000119f48 pc=0x55641c3de105
runtime.main()
/usr/local/go/src/runtime/proc.go:250 +0x213 fp=0xc000119fe0 sp=0xc000119f80 pc=0x55641c1f4d33
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc000119fe8 sp=0xc000119fe0 pc=0x55641c220b61
rax 0xffffff2f
rbx 0x16c8002382a0
rcx 0x0
rdx 0x1
rdi 0x16c8002180c0
rsi 0xffffff2f
rbp 0x7f2f38706d50
rsp 0x7f2f38706d18
r8 0xc000080000
r9 0x0
r10 0x8
r11 0x10
r12 0xc0000184a0
r13 0x0
r14 0x16c8002382b0
r15 0x16c80023e070
rip 0x7f2f61201f03
rflags 0x202
cs 0x33
fs 0x0
gs 0x0
root@80b5520f4a27:/code/cronet-go#
As a full time Linux user, I can compile and use this library in my project just fine on my machine but I also have a developer in my team who is using Windows. I spun up a VM to try and build the project and was met with a nightmare of compilation issues trying to get CGO working on Windows.
I learned that CGO doesn't really support Windows all that well and only supports MINGW for now. So I installed the native compilation toolset from https://www.msys2.org/#installation. I have the following packages installed:
# pacman -Qe
base 2022.06-1
base-devel 2022.12-2
filesystem 2023.02.07-1
lld 11.0.0-5
mingw-w64-i686-binutils 2.41-2
mingw-w64-i686-crt-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-gcc 13.2.0-2
mingw-w64-i686-gcc-ada 13.2.0-2
mingw-w64-i686-gcc-fortran 13.2.0-2
mingw-w64-i686-gcc-libgfortran 13.2.0-2
mingw-w64-i686-gcc-libs 13.2.0-2
mingw-w64-i686-gcc-objc 13.2.0-2
mingw-w64-i686-gdb 13.2-3
mingw-w64-i686-gdb-multiarch 13.2-3
mingw-w64-i686-headers-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-libgccjit 13.2.0-2
mingw-w64-i686-libmangle-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-libwinpthread-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-make 4.4-2
mingw-w64-i686-pkgconf 1~2.0.3-2
mingw-w64-i686-tools-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-winpthreads-git 11.0.0.r239.g037ba0184-1
mingw-w64-i686-winstorecompat-git 11.0.0.r239.g037ba0184-1
mingw-w64-ucrt-x86_64-gcc 13.2.0-2
mingw-w64-x86_64-binutils 2.41-2
mingw-w64-x86_64-clang 17.0.2-2
mingw-w64-x86_64-crt-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-gcc 13.2.0-2
mingw-w64-x86_64-gcc-ada 13.2.0-2
mingw-w64-x86_64-gcc-fortran 13.2.0-2
mingw-w64-x86_64-gcc-libgfortran 13.2.0-2
mingw-w64-x86_64-gcc-libs 13.2.0-2
mingw-w64-x86_64-gcc-objc 13.2.0-2
mingw-w64-x86_64-gdb 13.2-3
mingw-w64-x86_64-gdb-multiarch 13.2-3
mingw-w64-x86_64-headers-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-libgccjit 13.2.0-2
mingw-w64-x86_64-libmangle-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-libwinpthread-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-make 4.4-2
mingw-w64-x86_64-pkgconf 1~2.0.3-2
mingw-w64-x86_64-tools-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-winpthreads-git 11.0.0.r239.g037ba0184-1
mingw-w64-x86_64-winstorecompat-git 11.0.0.r239.g037ba0184-1
msys2-runtime 3.4.9-2
And with the appropriate environment variables set:
go env -w CGO_ENABLED=1
go env -w CC=clang
I get these warnings and errors when I try to build an example with // #cgo LDFLAGS: -fuse-ld=lld -Wl,--build-id=sha1 -fPIC -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--icf=all -Wl,--color-diagnostics -Wl,-mllvm,-instcombine-lower-dbg-declare=0 -flto=thin -Wl,--thinlto-jobs=all -Wl,--thinlto-cache-dir=thinlto-cache -Wl,--thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000 -Wl,-mllvm,-import-instr-limit=30 -fwhole-program-vtables -m64 -no-canonical-prefixes -rdynamic -Wl,-z,defs -Wl,--as-needed -Wl,--lto-O2 -pie -Wl,--disable-new-dtags -ldl -lpthread -lrt ./build/windows/amd64/cronet.dll -Wl,-rpath,$ORIGIN
:
# CGO_LDFLAGS_ALLOW=.* go build ./cmd/example/main.go
# github.com/sagernet/cronet-go
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:49:35: warning: redeclaration of 'cronetBidirectionalStreamOnStreamReady' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:50:35: warning: redeclaration of 'cronetBidirectionalStreamOnResponseHeadersReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:51:35: warning: redeclaration of 'cronetBidirectionalStreamOnReadCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:52:35: warning: redeclaration of 'cronetBidirectionalStreamOnWriteCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:10:14: note: previous declaration is here
cgo-gcc-export-header-prolog:53:35: warning: redeclaration of 'cronetBidirectionalStreamOnResponseTrailersReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:11:14: note: previous declaration is here
cgo-gcc-export-header-prolog:54:35: warning: redeclaration of 'cronetBidirectionalStreamOnSucceed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:12:14: note: previous declaration is here
cgo-gcc-export-header-prolog:55:35: warning: redeclaration of 'cronetBidirectionalStreamOnFailed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:13:14: note: previous declaration is here
cgo-gcc-export-header-prolog:56:35: warning: redeclaration of 'cronetBidirectionalStreamOnCanceled' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
bidirectional_stream_impl.go:14:14: note: previous declaration is here
cgo-gcc-export-header-prolog:57:35: warning: redeclaration of 'cronetBufferCallbackOnDestroy' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
buffer_callback_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:58:35: warning: redeclaration of 'cronetExecutorExecute' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
executor_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:59:38: warning: redeclaration of 'cronetUploadDataProviderGetLength' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:6:17: note: previous declaration is here
cgo-gcc-export-header-prolog:60:35: warning: redeclaration of 'cronetUploadDataProviderRead' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:61:35: warning: redeclaration of 'cronetUploadDataProviderRewind' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:62:35: warning: redeclaration of 'cronetUploadDataProviderClose' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
upload_data_provider_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:63:35: warning: redeclaration of 'cronetURLRequestCallbackOnRedirectReceived' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:64:35: warning: redeclaration of 'cronetURLRequestCallbackOnResponseStarted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:7:14: note: previous declaration is here
cgo-gcc-export-header-prolog:65:35: warning: redeclaration of 'cronetURLRequestCallbackOnReadCompleted' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:8:14: note: previous declaration is here
cgo-gcc-export-header-prolog:66:35: warning: redeclaration of 'cronetURLRequestCallbackOnSucceeded' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:9:14: note: previous declaration is here
cgo-gcc-export-header-prolog:67:35: warning: redeclaration of 'cronetURLRequestCallbackOnFailed' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:10:14: note: previous declaration is here
cgo-gcc-export-header-prolog:68:35: warning: redeclaration of 'cronetURLRequestCallbackOnCanceled' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_callback_impl.go:11:14: note: previous declaration is here
cgo-gcc-export-header-prolog:69:35: warning: redeclaration of 'cronetURLRequestFinishedInfoListenerOnRequestFinished' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_finished_info_impl.go:6:14: note: previous declaration is here
cgo-gcc-export-header-prolog:70:35: warning: redeclaration of 'cronetURLRequestStatusListenerOnStatus' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
url_request_status_listener_impl.go:6:14: note: previous declaration is here
# command-line-arguments
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running clang failed: exit status 1
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-pie' [-Wunused-command-line-argument]
lld: error: unknown argument: --build-id=sha1
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: --color-diagnostics
lld: error: unknown argument: --thinlto-jobs=all
lld: error: unknown argument: --thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000
lld: error: unknown argument: -z
lld: error: unknown argument: --as-needed
lld: error: unknown argument: --lto-O2
lld: error: unknown argument: --disable-new-dtags
lld: error: unknown argument: -rpath
lld: error: unknown argument: --build-id=sha1
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: -z
lld: error: unknown argument: --color-diagnostics
lld: error: unknown argument: --thinlto-jobs=all
lld: error: unknown argument: --thinlto-cache-policy=cache_size=10%:cache_size_bytes=40g:cache_size_files=100000
lld: error: unknown argument: -z
lld: error: too many errors emitted, stopping now
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I hope I didn't forget to mention anything because I tried a lot of things. Let me know and I'll dig for it.
Do you have an idea how one could get this setup working?
Another approach I haven't tried yet is cross-compilation from a Linux machine to Windows, but the problem is that then my colleague would have to switch to Linux which he probably doesn't want (yet?) 😅 And if WSL works too then I'm not sure how/if debugging would work in that case.
Thanks a lot for your help!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.