From 4688c028f7a0781e6bf724dedb0f04e3e137cd28 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 20 Sep 2018 12:58:12 -0500 Subject: [PATCH 01/11] Updated to Tor 0.3.5.1-alpha for issue #8 --- README.md | 2 +- tor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8552c94..2eabb76 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ submodules are: * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` -* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.3.7` +* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.1-alpha` Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons. diff --git a/tor b/tor index 035a351..1f9055c 160000 --- a/tor +++ b/tor @@ -1 +1 @@ -Subproject commit 035a35178c92da94400c13767a265053ff6c8413 +Subproject commit 1f9055c8845920e0aad8fc0cf3fd71b19905b2cb From a03af858acbb95c8cdc85a4ec4ab275d7145a0a2 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 20 Sep 2018 15:36:41 -0500 Subject: [PATCH 02/11] Add show-libs on build script and work for new OpenSSL version --- build.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/build.go b/build.go index 581e9b0..88128e2 100644 --- a/build.go +++ b/build.go @@ -23,7 +23,7 @@ func main() { flag.StringVar(&autopointPath, "autopoint-path", "/usr/local/opt/gettext/bin", "OSX: Directory that contains autopoint binary") flag.Parse() if len(flag.Args()) != 1 { - log.Fatal("Missing command. Can be build-all, build-, clean-all, or clean-") + log.Fatal("Missing command. Can be build-all, build-, clean-all, clean-, or show-libs") } if err := run(flag.Args()[0]); err != nil { log.Fatal(err) @@ -38,8 +38,10 @@ func run(cmd string) error { return build(cmd[6:]) } else if strings.HasPrefix(cmd, "clean-") { return clean(cmd[6:]) + } else if cmd == "show-libs" { + return showLibs() } - return fmt.Errorf("Invalid command: %v. Should be build-all, build-, clean-all, or clean-", cmd) + return fmt.Errorf("Invalid command: %v. Should be build-all, build-, clean-all, clean-, or show-libs", cmd) } func getAbsCurrDir() string { @@ -103,6 +105,7 @@ func build(folder string) error { } if runtime.GOOS == "windows" { cmds[0] = append(cmds[0], "mingw64") + cmds[0][0] = "perl" cmds[0][1] = "./Configure" } else if runtime.GOOS == "darwin" { cmds[0] = append(cmds[0], "darwin64-x86_64-cc") @@ -151,7 +154,9 @@ func build(folder string) error { var env []string var torConf []string if runtime.GOOS == "windows" { - env = []string{"LIBS=-lcrypt32"} + // This was only -lcrypt32 but the configure script for Tor puts that before -lssl and -lcrypto which + // we have learned, emperically, is required after those so we put all three here + env = []string{"LIBS=-lssl -lcrypto -lcrypt32 -lgdi32 -lws2_32"} } torConf = []string{"sh", "./configure", "--prefix=" + pwd + "/dist", "--disable-gcc-hardening", "--disable-system-torrc", "--disable-asciidoc", @@ -233,3 +238,47 @@ func runCmd(folder string, env []string, cmd string, args ...string) error { } return c.Run() } + +func showLibs() error { + // Ask Tor for their libs + cmd := exec.Command("make", "show-libs") + cmd.Dir = "tor" + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("Failed 'make show-libs' in tor: %v", err) + } + // Key is dir + libSets := [][]string{} + for _, lib := range strings.Split(strings.TrimSpace(string(out)), " ") { + dir, file := path.Split(lib) + dir = path.Join("tor", dir) + file = strings.TrimPrefix(strings.TrimSuffix(file, ".a"), "lib") + found := false + for i, libSet := range libSets { + if libSet[0] == dir { + libSets[i] = append(libSets[i], file) + found = true + break + } + } + if !found { + libSets = append(libSets, []string{dir, file}) + } + } + // Add the rest of the known libs + libSets = append(libSets, + []string{"libevent/dist/lib", "event"}, + []string{"xz/dist/lib", "lzma"}, + []string{"zlib/dist/lib", "z"}, + []string{"openssl/dist/lib", "ssl", "crypto"}, + ) + // Dump em + for _, libSet := range libSets { + fmt.Print("-L" + libSet[0]) + for _, lib := range libSet[1:] { + fmt.Print(" -l" + lib) + } + fmt.Println() + } + return nil +} From d54a07034222ae16bbc2064ec010f7f9022b5b8d Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 20 Sep 2018 15:47:47 -0500 Subject: [PATCH 03/11] Update OpenSSL to 1.1.0i for issue #5 --- README.md | 2 +- openssl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2eabb76..edb185a 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This project helps compile Tor into a static lib for use in other projects. The dependencies are in this repository as submodules so this repository needs to be cloned with `--recursive`. The submodules are: -* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_0_2o` +* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_1_0i` * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` diff --git a/openssl b/openssl index 3ce7bc4..97c0959 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 3ce7bc40a3c48da1c96c2d04c10045bd797c6aa3 +Subproject commit 97c0959f27b294fe1eb10b547145ebef2524b896 From 9af842395f4ffb8cc7a18c278ffb7d81ab9a78c9 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 20 Sep 2018 16:05:23 -0500 Subject: [PATCH 04/11] README update for show-libs --- README.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index edb185a..58298f4 100644 --- a/README.md +++ b/README.md @@ -70,21 +70,13 @@ are being run, add `-verbose` before the command. ## Using -Once the libs have been compiled, they can be used to link with your program. Below is the list of each dir (relative to -this repository root) and the library names inside the dirs. Library names are just the filenames without the "lib" -prefix of ".a" extension. When using something like `ld` or `LDFLAGS`, the directories (i.e. `-L`) and the libs -(i.e. `-l`) must be given in the order below: - -* `tor/src/or` - `tor` -* `tor/src/common` - `or`, `or-crypto`, `curve25519_donna`, `or-ctime`, and `or-event` -* `tor/src/trunnel` - `or-trunnel` -* `tor/src/ext/keccak-tiny` - `keccak-tiny` -* `tor/src/ext/ed25519/ref10` - `ed25519_ref10` -* `tor/src/ext/ed25519/donna` - `ed25519_donna` -* `libevent/dist/lib` - `event` -* `xz/dist/lib` - `lzma` -* `zlib/dist/lib` - `z` -* `openssl/dist/lib` - `ssl`, and `crypto` +Once the libs have been compiled, they can be used to link with your program. Due to recent refactorings within the Tor +source, the libraries are not listed here but instead listed when executing: + + go run build.go show-libs + +This lists directories (relative, prefixed with `-L`) followed by lib names (file sans `lib` prefix and sans `.a` +extension, prefixed with `-l`) as might be used in `ld`. The OS-specific system libs that have to be referenced (i.e. `-l`) are: From cb3acaea9aac2e3ce32bc8ea3abe112b070565e0 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Fri, 21 Sep 2018 09:22:58 -0500 Subject: [PATCH 05/11] Backed out to OpenSSL 1.0.2p for issue #5 --- build.go | 5 +---- openssl | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/build.go b/build.go index 88128e2..9a5553e 100644 --- a/build.go +++ b/build.go @@ -105,7 +105,6 @@ func build(folder string) error { } if runtime.GOOS == "windows" { cmds[0] = append(cmds[0], "mingw64") - cmds[0][0] = "perl" cmds[0][1] = "./Configure" } else if runtime.GOOS == "darwin" { cmds[0] = append(cmds[0], "darwin64-x86_64-cc") @@ -154,9 +153,7 @@ func build(folder string) error { var env []string var torConf []string if runtime.GOOS == "windows" { - // This was only -lcrypt32 but the configure script for Tor puts that before -lssl and -lcrypto which - // we have learned, emperically, is required after those so we put all three here - env = []string{"LIBS=-lssl -lcrypto -lcrypt32 -lgdi32 -lws2_32"} + env = []string{"LIBS=-lcrypt32 -lgdi32"} } torConf = []string{"sh", "./configure", "--prefix=" + pwd + "/dist", "--disable-gcc-hardening", "--disable-system-torrc", "--disable-asciidoc", diff --git a/openssl b/openssl index 97c0959..e71ebf2 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 97c0959f27b294fe1eb10b547145ebef2524b896 +Subproject commit e71ebf275da66dfd601c92e0e80a35114c32f6f8 From 606074fa223167d8019e90fe003d7b2ef1dc313d Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Fri, 21 Sep 2018 12:35:58 -0500 Subject: [PATCH 06/11] set OpenSSL in README to 1.0.2p --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 58298f4..d0373f3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This project helps compile Tor into a static lib for use in other projects. The dependencies are in this repository as submodules so this repository needs to be cloned with `--recursive`. The submodules are: -* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_1_0i` +* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_0_2p` * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` From 3560e475350a2d5ebfd39f7d6c8327d7ca9df5e6 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Fri, 21 Sep 2018 13:34:46 -0500 Subject: [PATCH 07/11] Upgrade to 0.3.5.2-alpha --- README.md | 2 +- tor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0373f3..d51af19 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ submodules are: * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` -* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.1-alpha` +* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.2-alpha` Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons. diff --git a/tor b/tor index 1f9055c..e62d92b 160000 --- a/tor +++ b/tor @@ -1 +1 @@ -Subproject commit 1f9055c8845920e0aad8fc0cf3fd71b19905b2cb +Subproject commit e62d92be5a9f1503d67d7d03e10eadcfc6be9b33 From 5512b93938889a66358740348f2e622eeed54648 Mon Sep 17 00:00:00 2001 From: cretz Date: Tue, 16 Oct 2018 11:36:28 -0500 Subject: [PATCH 08/11] Update to tor-0.3.5.2-alpha --- README.md | 2 +- tor | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13f3d8c..35bd0a7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ submodules are: * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` -* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.1-alpha` +* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.2-alpha` Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons. diff --git a/tor b/tor index 1f9055c..e62d92b 160000 --- a/tor +++ b/tor @@ -1 +1 @@ -Subproject commit 1f9055c8845920e0aad8fc0cf3fd71b19905b2cb +Subproject commit e62d92be5a9f1503d67d7d03e10eadcfc6be9b33 From 219f2f927a9a5ef6e41d2c658aa82bae489b1836 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Mon, 26 Nov 2018 12:21:32 -0600 Subject: [PATCH 09/11] Add pthread static link note as mentioned in https://github.com/cretz/bine/pull/20 --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d51af19..9299b50 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,7 @@ The OS-specific system libs that have to be referenced (i.e. `-l`) are: * Linux/macOS - `m` * Windows (MinGW) - `ws2_32`, `crypt32`, and `gdi32` + +The OS-specific system libs that have to be explicitly statically linked (i.e. `-Wl,-Bstatic -l`) are: + +* Windows (MinGW) - `pthread` From d404f8150e12b2619664beb8ff1d33b7d75b8e5d Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 17 Jan 2019 09:38:34 -0600 Subject: [PATCH 10/11] Updated Tor to tag tor-0.3.5.7 for issue #8 --- tor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tor b/tor index e62d92b..9beb085 160000 --- a/tor +++ b/tor @@ -1 +1 @@ -Subproject commit e62d92be5a9f1503d67d7d03e10eadcfc6be9b33 +Subproject commit 9beb085c10562a257c08abcee43434533d4fa96e From b1d03f78a5b1347b24c27f3dd869fe0703fd9fd1 Mon Sep 17 00:00:00 2001 From: Chad Retz Date: Thu, 17 Jan 2019 10:42:02 -0600 Subject: [PATCH 11/11] Update to 0.3.5.7 for issue #8 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc79c0d..7372800 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ submodules are: * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` -* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.2-alpha` +* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.7` Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons.