From 7ececbe3fcb2fe913019d85e4ee94299c19a9084 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Tue, 12 Dec 2017 16:56:15 -0800 Subject: [PATCH 1/8] Add support for openssl 1.1.0 If your system has openssl 1.1.0 and you need to use the crypto or ssl packages you must define openssl_1.1.0 when invoking ponyc. Specifically, there are ifdef "openssl_1.1.0" statements in packages/crypto and packages/net/ssl which can use the openssl 1.1.0 API's. When compiling using ponyc/Makefile and targeting various tests you need to set OPENSSL=-Dopenssl_1.1.0. For instance, if targeting "test" the command line would be: make OPENSSL=-Dopenssl_1.1.0 test If you are compiling pony programs using ponyc in your own Makefile or directly on the command line and the program uses crypto or ssl then pass -Dopenssl_1.1.0 on the ponyc command line. For instance, to compile stdlib: ./build/release/ponyc -Dopenssl_1.1.0 packages/stdlib This resolves issue [#1838](https://github.com/ponylang/ponyc/issues/1838) --- Makefile | 22 ++-- README.md | 3 + packages/crypto/digest.pony | 48 +++++++-- packages/net/ssl/_ssl_init.pony | 26 ++++- packages/net/ssl/_ssl_versions.pony | 4 + packages/net/ssl/ssl_context.pony | 151 +++++++++++++++++++++++----- packages/net/ssl/ssl_versions.pony | 18 ++++ packages/net/ssl/x509.pony | 19 +++- 8 files changed, 242 insertions(+), 49 deletions(-) create mode 100644 packages/net/ssl/_ssl_versions.pony create mode 100644 packages/net/ssl/ssl_versions.pony diff --git a/Makefile b/Makefile index dde4114bca..664a6bd105 100644 --- a/Makefile +++ b/Makefile @@ -292,6 +292,10 @@ ifeq ($(runtime-bitcode),yes) endif endif +ifneq (,$(OPENSSL)) + $(warning targeting openssl 1.1.0) +endif + makefile_abs_path := $(realpath $(lastword $(MAKEFILE_LIST))) packages_abs_src := $(shell dirname $(makefile_abs_path))/packages @@ -859,10 +863,10 @@ benchmark: all @$(PONY_BUILD_DIR)/libponyrt.benchmarks stdlib-debug: all - $(PONY_BUILD_DIR)/ponyc -d --checktree --verify packages/stdlib + $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d --checktree --verify packages/stdlib stdlib: all - $(PONY_BUILD_DIR)/ponyc --checktree --verify packages/stdlib + $(PONY_BUILD_DIR)/ponyc $(OPENSSL) --checktree --verify packages/stdlib test-stdlib-debug: stdlib-debug ./stdlib --sequential @@ -873,12 +877,12 @@ test-stdlib: stdlib test: all @$(PONY_BUILD_DIR)/libponyc.tests @$(PONY_BUILD_DIR)/libponyrt.tests - @$(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib test-examples: all - @PONYPATH=. $(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify examples + @PONYPATH=. $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify examples @./examples1 @rm examples1 @@ -886,21 +890,21 @@ test-ci: all @$(PONY_BUILD_DIR)/ponyc --version @$(PONY_BUILD_DIR)/libponyc.tests @$(PONY_BUILD_DIR)/libponyrt.tests - @$(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib - @$(PONY_BUILD_DIR)/ponyc --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib - @PONYPATH=. $(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify examples + @PONYPATH=. $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify examples @./examples1 @rm examples1 - @$(PONY_BUILD_DIR)/ponyc --antlr > pony.g.new + @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) --antlr > pony.g.new @diff pony.g pony.g.new @rm pony.g.new docs: all - $(SILENT)$(PONY_BUILD_DIR)/ponyc packages/stdlib --docs --pass expr + $(SILENT)$(PONY_BUILD_DIR)/ponyc $(OPENSSL) packages/stdlib --docs --pass expr $(SILENT)cp .docs/extra.js stdlib-docs/docs/ docs-online: docs diff --git a/README.md b/README.md index b35e67f5e1..8b86b64c82 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ We have a couple resources designed to help you learn, we suggest starting with * [Tutorial](http://tutorial.ponylang.org). * [Pony Patterns](http://patterns.ponylang.org) cookbook is in progress * [Standard library docs](http://stdlib.ponylang.org/). +* [Build Problems, see FAQ Compiling](https://www.ponylang.org/faq/#compiling). If you are looking for an answer "right now", we suggest you give our IRC channel a try. It's #ponylang on Freenode. If you ask a question, be sure to hang around until you get an answer. If you don't get one, or IRC isn't your thing, we have a friendly mailing list you can try. Whatever your question is, it isn't dumb, and we won't get annoyed. @@ -40,6 +41,8 @@ If you want a quick way to test or run code, checkout the [Playground](https://p # Installation +Pony supports LLVM 3.9 and on an experimental basis it supports LLVM 4.0 and 5.0. In addition, support for OpenSSL 1.1.0 was recently added for systems such as the Debian Stretch and Arch Linux, see [FAQ Compiling](https://www.ponylang.org/faq/#compiling) for additional information. + ## Using Docker Want to use the latest revision of Pony source, but don't want to build from source yourself? You can run the `ponylang/ponyc` Docker container, which is created from an automated build at each commit to master. diff --git a/packages/crypto/digest.pony b/packages/crypto/digest.pony index 9b88fb4565..ed6cc07322 100644 --- a/packages/crypto/digest.pony +++ b/packages/crypto/digest.pony @@ -18,7 +18,11 @@ class Digest Use the MD5 algorithm to calculate the hash. """ _digest_size = 16 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_md5[Pointer[_EVPMD]](), USize(0)) new ripemd160() => @@ -26,7 +30,11 @@ class Digest Use the RIPEMD160 algorithm to calculate the hash. """ _digest_size = 20 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_ripemd160[Pointer[_EVPMD]](), USize(0)) new sha1() => @@ -34,7 +42,11 @@ class Digest Use the SHA1 algorithm to calculate the hash. """ _digest_size = 20 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_sha1[Pointer[_EVPMD]](), USize(0)) new sha224() => @@ -42,7 +54,11 @@ class Digest Use the SHA256 algorithm to calculate the hash. """ _digest_size = 28 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_sha224[Pointer[_EVPMD]](), USize(0)) new sha256() => @@ -50,7 +66,11 @@ class Digest Use the SHA256 algorithm to calculate the hash. """ _digest_size = 32 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_sha256[Pointer[_EVPMD]](), USize(0)) new sha384() => @@ -58,7 +78,11 @@ class Digest Use the SHA384 algorithm to calculate the hash. """ _digest_size = 48 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_sha384[Pointer[_EVPMD]](), USize(0)) new sha512() => @@ -66,7 +90,11 @@ class Digest Use the SHA512 algorithm to calculate the hash. """ _digest_size = 64 - _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + ifdef "openssl_1.1.0" then + _ctx = @EVP_MD_CTX_new[Pointer[_EVPCTX]]() + else + _ctx = @EVP_MD_CTX_create[Pointer[_EVPCTX]]() + end @EVP_DigestInit_ex[None](_ctx, @EVP_sha512[Pointer[_EVPMD]](), USize(0)) fun ref append(input: ByteSeq) ? => @@ -90,7 +118,11 @@ class Digest @pony_alloc[Pointer[U8]](@pony_ctx[Pointer[None] iso](), size), size) end @EVP_DigestFinal_ex[None](_ctx, digest.cpointer(), Pointer[USize]) - @EVP_MD_CTX_cleanup[None](_ctx) + ifdef "openssl_1.1.0" then + @EVP_MD_CTX_free[None](_ctx) + else + @EVP_MD_CTX_cleanup[None](_ctx) + end let h = (consume digest).array() _hash = h h diff --git a/packages/net/ssl/_ssl_init.pony b/packages/net/ssl/_ssl_init.pony index 26a48d26c1..07d6589713 100644 --- a/packages/net/ssl/_ssl_init.pony +++ b/packages/net/ssl/_ssl_init.pony @@ -2,12 +2,30 @@ use "path:/usr/local/opt/libressl/lib" if osx use "lib:ssl" use "lib:crypto" +use @OPENSSL_init_ssl[I32](opts: U64, settings: Pointer[_OpenSslInitSettings]) +use @OPENSSL_INIT_new[Pointer[_OpenSslInitSettings]]() + +primitive _OpenSslInitSettings + +// From https://github.com/ponylang/ponyc/issues/330 +primitive _OpenSslInitNoLoadSslStrings fun val apply(): U64 => 0x00100000 +primitive _OpenSslInitLoadSslStrings fun val apply(): U64 => 0x00200000 +primitive _OpenSslInitNoLoadCryptoStrings fun val apply(): U64 => 0x00000001 +primitive _OpenSslInitLoadCryptoStrings fun val apply(): U64 => 0x00000002 + primitive _SSLInit """ This initialises SSL when the program begins. """ fun _init() => - @SSL_load_error_strings[None]() - @SSL_library_init[I32]() - let cb = @ponyint_ssl_multithreading[Pointer[U8]](@CRYPTO_num_locks[I32]()) - @CRYPTO_set_locking_callback[None](cb) + ifdef "openssl_1.1.0" then + let settings = @OPENSSL_INIT_new() + @OPENSSL_init_ssl(_OpenSslInitLoadSslStrings.apply() + + _OpenSslInitLoadCryptoStrings.apply(), settings) + else + @SSL_load_error_strings[None]() + @SSL_library_init[I32]() + let cb = + @ponyint_ssl_multithreading[Pointer[U8]](@CRYPTO_num_locks[I32]()) + @CRYPTO_set_locking_callback[None](cb) + end diff --git a/packages/net/ssl/_ssl_versions.pony b/packages/net/ssl/_ssl_versions.pony new file mode 100644 index 0000000000..c37459ddd2 --- /dev/null +++ b/packages/net/ssl/_ssl_versions.pony @@ -0,0 +1,4 @@ +primitive _SslCtrlSetMinProtoVersion fun val apply(): I32 => 123 +primitive _SslCtrlSetMaxProtoVersion fun val apply(): I32 => 124 +primitive _SslCtrlGetMinProtoVersion fun val apply(): I32 => 130 +primitive _SslCtrlGetMaxProtoVersion fun val apply(): I32 => 131 diff --git a/packages/net/ssl/ssl_context.pony b/packages/net/ssl/ssl_context.pony index af18d67355..0102aa5be4 100644 --- a/packages/net/ssl/ssl_context.pony +++ b/packages/net/ssl/ssl_context.pony @@ -3,11 +3,46 @@ use "files" use @SSL_CTX_ctrl[ILong]( ctx: Pointer[_SSLContext] tag, op: I32, - arg: ILong, + arg: ULong, parg: Pointer[None]) +use @SSLv23_method[Pointer[None]]() +use @TLS_method[Pointer[None]]() +use @SSL_CTX_new[Pointer[_SSLContext]](method: Pointer[None]) +use @SSL_CTX_free[None](ctx: Pointer[_SSLContext] tag) +use @SSL_CTX_clear_options[ULong](ctx: Pointer[_SSLContext] tag, opts: ULong) +use @SSL_CTX_set_options[ULong](ctx: Pointer[_SSLContext] tag, opts: ULong) + primitive _SSLContext +primitive _SslCtrlSetOptions fun val apply(): I32 => 32 +primitive _SslCtrlClearOptions fun val apply(): I32 => 77 + +// These are the SSL_OP_NO_{SSL|TLS}vx{_x} in ssl.h. +// Since Pony doesn't allow underscore we use camel case +// and began them with underscore to keep them private. +// Also, in the version strings the "v" becomes "V" and +// the underscore "_" becomes "u". So SSL_OP_NO_TLSv1_2 +// _SslOpNo_TlsV1u2. +primitive _SslOpNoSslV2 fun val apply(): ULong => 0x01000000 // 0 in 1.1 +primitive _SslOpNoSslV3 fun val apply(): ULong => 0x02000000 +primitive _SslOpNoTlsV1 fun val apply(): ULong => 0x04000000 +primitive _SslOpNoTlsV1u2 fun val apply(): ULong => 0x08000000 +primitive _SslOpNoTlsV1u1 fun val apply(): ULong => 0x10000000 +primitive _SslOpNoTlsV1u3 fun val apply(): ULong => 0x20000000 + +primitive _SslOpNoDtlsV1 fun val apply(): ULong => 0x04000000 +primitive _SslOpNoDtlsV1u2 fun val apply(): ULong => 0x08000000 + +// Defined as SSL_OP_NO_SSL_MASK in ssl.h +primitive _SslOpNoSslMask fun val apply(): ULong => + (_SslOpNoSslV3.apply() + _SslOpNoTlsV1.apply() + _SslOpNoTlsV1u1.apply() + + _SslOpNoTlsV1u2.apply() + _SslOpNoTlsV1u3.apply()) + +// Defined as SSL_OP_NO_DTLS_MASK in ssl.h +primitive _SslOpNoDtlsMask fun val apply(): ULong => + (_SslOpNoDtlsV1.apply() + _SslOpNoDtlsV1u2.apply()) + class val SSLContext """ An SSL context is used to create SSL sessions. @@ -20,20 +55,37 @@ class val SSLContext """ Create an SSL context. """ - _ctx = @SSL_CTX_new[Pointer[_SSLContext]](@SSLv23_method[Pointer[None]]()) + ifdef "openssl_1.1.0" then + _ctx = @SSL_CTX_new(@TLS_method()) + + // Allow only newer ciphers. + try + set_min_proto_version(Tls1u2Version.apply())? + set_max_proto_version(SslAutoVersion.apply())? + end + else + _ctx = @SSL_CTX_new(@SSLv23_method()) - // Disable older protocols, allow only TLSv1.2 and above - // set SSL_OP_NO_SSLv2 - @SSL_CTX_ctrl(_ctx, 32, 0x01000000, Pointer[None]) + // Disable "all" SSL/TSL options + _set_options(_SslOpNoSslMask.apply() + _SslOpNoSslV2.apply()) - // set SSL_OP_NO_SSLv3 - @SSL_CTX_ctrl(_ctx, 32, 0x02000000, Pointer[None]) + // Allow only newer ciphers + allow_tls_v1_2(true) + end - // set SSL_OP_NO_TLSv1 - @SSL_CTX_ctrl(_ctx, 32, 0x04000000, Pointer[None]) + fun _set_options(opts: ULong) => + ifdef "openssl_1.1.0" then + @SSL_CTX_set_options(_ctx, opts) + else + @SSL_CTX_ctrl(_ctx, _SslCtrlSetOptions.apply(), opts, Pointer[None]) + end - // set SSL_OP_NO_TLSv1_1 - @SSL_CTX_ctrl(_ctx, 32, 0x10000000, Pointer[None]) + fun _clear_options(opts: ULong) => + ifdef "openssl_1.1.0" then + @SSL_CTX_clear_options(_ctx, opts) + else + @SSL_CTX_ctrl(_ctx, _SslCtrlClearOptions.apply(), opts, Pointer[None]) + end fun client(hostname: String = ""): SSL iso^ ? => """ @@ -127,45 +179,94 @@ class val SSLContext @SSL_CTX_set_verify_depth[None](_ctx, depth) end + fun ref set_min_proto_version(version: ULong) ? => + """ + Set minimum protocol version. Set to SslAutoVersion, 0, + to automatically manage lowest version. + + Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, + Tls1u2Version, Tls1u3Version, Dtls1Version, + Dtls1u2Version + """ + let result = @SSL_CTX_ctrl(_ctx, _SslCtrlSetMinProtoVersion.apply(), + version, Pointer[None]) + if result == 0 then + error + end + + fun ref get_min_proto_version(): ILong => + """ + Get minimum protocol version. Returns SslAutoVersion, 0, + when automatically managing lowest version. + + Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, + Tls1u2Version, Tls1u3Version, Dtls1Version, + Dtls1u2Version + """ + @SSL_CTX_ctrl(_ctx, _SslCtrlGetMinProtoVersion.apply(), 0, Pointer[None]) + + fun ref set_max_proto_version(version: ULong) ? => + """ + Set maximum protocol version. Set to SslAutoVersion, 0, + to automatically manage higest version. + + Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, + Tls1u2Version, Tls1u3Version, Dtls1Version, + Dtls1u2Version + """ + let result = @SSL_CTX_ctrl(_ctx, _SslCtrlSetMaxProtoVersion.apply(), + version, Pointer[None]) + if result == 0 then + error + end + + fun ref get_max_proto_version(): ILong => + """ + Get maximum protocol version. Returns SslAutoVersion, 0, + when automatically managing highest version. + + Supported versions: Ssl3Version, Tls1Version, Tls1u1Version, + Tls1u2Version, Tls1u3Version, Dtls1Version, + Dtls1u2Version + """ + @SSL_CTX_ctrl(_ctx, _SslCtrlGetMaxProtoVersion.apply(), 0, Pointer[None]) + fun ref allow_tls_v1(state: Bool) => """ Allow TLS v1. Defaults to false. + Deprecated: use set_min_proto_version and set_max_proto_version """ if not _ctx.is_null() then if state then - // clear SSL_OP_NO_TLSv1 - @SSL_CTX_ctrl(_ctx, 77, 0x04000000, Pointer[None]) + _clear_options(_SslOpNoTlsV1.apply()) else - // set SSL_OP_NO_TLSv1 - @SSL_CTX_ctrl(_ctx, 32, 0x04000000, Pointer[None]) + _set_options(_SslOpNoTlsV1.apply()) end end fun ref allow_tls_v1_1(state: Bool) => """ Allow TLS v1.1. Defaults to false. + Deprecated: use set_min_proto_version and set_max_proto_version """ if not _ctx.is_null() then if state then - // clear SSL_OP_NO_TLSv1_1 - @SSL_CTX_ctrl(_ctx, 77, 0x10000000, Pointer[None]) + _clear_options(_SslOpNoTlsV1u1.apply()) else - // set SSL_OP_NO_TLSv1_1 - @SSL_CTX_ctrl(_ctx, 32, 0x10000000, Pointer[None]) + _set_options(_SslOpNoTlsV1u1.apply()) end end fun ref allow_tls_v1_2(state: Bool) => """ Allow TLS v1.2. Defaults to true. + Deprecated: use set_min_proto_version and set_max_proto_version """ if not _ctx.is_null() then if state then - // clear SSL_OP_NO_TLSv1_2 - @SSL_CTX_ctrl(_ctx, 77, 0x08000000, Pointer[None]) + _clear_options(_SslOpNoTlsV1u2.apply()) else - // set SSL_OP_NO_TLSv1_2 - @SSL_CTX_ctrl(_ctx, 32, 0x08000000, Pointer[None]) + _set_options(_SslOpNoTlsV1u2.apply()) end end @@ -174,7 +275,7 @@ class val SSLContext Free the SSL context. """ if not _ctx.is_null() then - @SSL_CTX_free[None](_ctx) + @SSL_CTX_free(_ctx) _ctx = Pointer[_SSLContext] end @@ -183,5 +284,5 @@ class val SSLContext Free the SSL context. """ if not _ctx.is_null() then - @SSL_CTX_free[None](_ctx) + @SSL_CTX_free(_ctx) end diff --git a/packages/net/ssl/ssl_versions.pony b/packages/net/ssl/ssl_versions.pony new file mode 100644 index 0000000000..83fd0481bf --- /dev/null +++ b/packages/net/ssl/ssl_versions.pony @@ -0,0 +1,18 @@ +primitive SslAutoVersion fun val apply(): ULong => 0x0 + +primitive Ssl3Version fun val apply(): ULong => 0x300 +primitive Tls1Version fun val apply(): ULong => 0x301 +primitive Tls1u1Version fun val apply(): ULong => 0x302 +primitive Tls1u2Version fun val apply(): ULong => 0x303 +primitive Tls1u3Version fun val apply(): ULong => 0x304 +primitive Dtls1Version fun val apply(): ULong => 0xFEFF +primitive Dtls1u2Version fun val apply(): ULong => 0xFEFD + +primitive TlsMinVersion fun val apply(): ULong => + Tls1Version.apply() +primitive TlsMaxVersion fun val apply(): ULong => + Tls1u3Version.apply() +primitive DtlsMinVersion fun val apply(): ULong => + Dtls1Version.apply() +primitive DtlsMaxVersion fun val apply(): ULong => + Dtls1u2Version.apply() diff --git a/packages/net/ssl/x509.pony b/packages/net/ssl/x509.pony index 5af398a72a..f8ae1c71a9 100644 --- a/packages/net/ssl/x509.pony +++ b/packages/net/ssl/x509.pony @@ -69,7 +69,12 @@ primitive X509 return array end - var name = @sk_pop[Pointer[_GeneralName]](stack) + var name = + ifdef "openssl_1.1.0" then + @OPENSSL_sk_pop[Pointer[_GeneralName]](stack) + else + @sk_pop[Pointer[_GeneralName]](stack) + end while not name.is_null() do var ptype = I32(0) @@ -109,10 +114,18 @@ primitive X509 end @GENERAL_NAME_free[None](name) - name = @sk_pop[Pointer[_GeneralName]](stack) + ifdef "openssl_1.1.0" then + name = @OPENSSL_sk_pop[Pointer[_GeneralName]](stack) + else + name = @sk_pop[Pointer[_GeneralName]](stack) + end end - @sk_free[None](stack) + ifdef "openssl_1.1.0" then + @OPENSSL_sk_free[None](stack) + else + @sk_free[None](stack) + end array fun _match_name(host: String, name: String): Bool => From abbe65de614758300b2d7ca7cb89f11c8b8fe70c Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Tue, 9 Jan 2018 23:55:42 -0800 Subject: [PATCH 2/8] Add Compile time option default_openssl When compiling ponyc if default_openssl=openssl_1.1.0 or default_openssl=openssl_0.9.0 is passed on the make command line then that parameter will becomce the default when compiling packages/crypto or packages/net/ssl. This default maybe overridden by passing -Dopenssl_1.1.0 or -Dopenssl_0.9.0 on the ponyc command line. --- Makefile | 15 +++++- src/libponyc/options/options.c | 94 ++++++++++++++++++++++++++++++++- src/libponyc/pkg/buildflagset.c | 29 ++++++++++ src/libponyc/pkg/buildflagset.h | 4 ++ src/ponyc/main.c | 10 ---- 5 files changed, 140 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 664a6bd105..ac1d611731 100644 --- a/Makefile +++ b/Makefile @@ -292,8 +292,14 @@ ifeq ($(runtime-bitcode),yes) endif endif +# default OPENSSL version +ifdef default_openssl + BUILD_FLAGS += -DPONY_DEFAULT_OPENSSL=\"$(default_openssl)\" + OPENSSL=-D$(default_openssl) +endif + ifneq (,$(OPENSSL)) - $(warning targeting openssl 1.1.0) + $(warning targeting openssl $(OPENSSL)) endif makefile_abs_path := $(realpath $(lastword $(MAKEFILE_LIST))) @@ -999,6 +1005,13 @@ help: @echo ' native (default)' @echo ' [any compiler supported architecture]' @echo + @echo 'Compile time default options:' + @echo ' default_pic=true Make --pic the default' + @echo ' default_openssl=Name Make Name the default openssl version' + @echo ' where Name is one of:' + @echo ' openssl_0.9.0' + @echo ' openssl_1.1.0' + @echo @echo 'USE OPTIONS:' @echo ' valgrind' @echo ' pooltrack' diff --git a/src/libponyc/options/options.c b/src/libponyc/options/options.c index 70716fa80a..c0ffb701d3 100644 --- a/src/libponyc/options/options.c +++ b/src/libponyc/options/options.c @@ -16,6 +16,8 @@ #include #include +#define MAYBE_UNUSED(x) (void)x + enum { OPT_VERSION, @@ -221,6 +223,85 @@ static void usage(void) ); } +static const char* valid_openssl_flags[] = + { "openssl_1.1.0", "openssl_0.9.0", NULL }; + + +static const char** get_valid_openssl_flags() +{ + return valid_openssl_flags; +} + + +static bool validate_openssl_flag(const char* name) +{ + for (const char** next = valid_openssl_flags; *next != NULL; next++) + { + if (0 == strcmp(*next, name)) + return true; + } + return false; +} + +/** + * Handle special cases of options like compile time defaults + * + * return CONTINUE if no errors else an ponyc_opt_process_t EXIT_XXX code. + */ +static ponyc_opt_process_t special_opt_processing(pass_opt_t *opt) +{ + // Suppress compiler errors due to conditional compilation + MAYBE_UNUSED(opt); + MAYBE_UNUSED((void*)get_valid_openssl_flags); + +#if defined(PONY_DEFAULT_PIC) + #if (PONY_DEFAULT_PIC == true) || (PONY_DEFAULT_PIC == false) + opt->pic = PONY_DEFAULT_PIC; + #else + #error "PONY_DEFAULT_PIC must be true or false" + #endif +#endif + +#if defined(USE_SCHEDULER_SCALING_PTHREADS) + // Defined "scheduler_scaling_pthreads" so that SIGUSR2 is made available for + // use by the signals package when not using signals for scheduler scaling + define_build_flag("scheduler_scaling_pthreads"); +#endif + +#if defined(PONY_DEFAULT_OPENSSL) + static char default_openssl[100]; + int n = snprintf(default_openssl, sizeof(default_openssl), "%s", + PONY_DEFAULT_OPENSSL); + if (n < 0) + { + printf("Error: %s\n", strerror(errno)); + return EXIT_255; + } + if ((size_t)n >= sizeof(default_openssl)) + { + printf("Error: PONY_DEFAULT_OPENSSL=\"%s\" and is %zu characters long" + ", maximum len=%zu\n", PONY_DEFAULT_OPENSSL, + strlen(PONY_DEFAULT_OPENSSL), sizeof(default_openssl)-1); + return EXIT_255; + } + if (!validate_openssl_flag(default_openssl)) + { + printf("Error: PONY_DEFAULT_OPENSSL=\"%s\" and should be one of:\n", + default_openssl); + for (const char** next = get_valid_openssl_flags(); *next != NULL; next++) + { + printf(" %s\n", *next); + } + return EXIT_255; + } + + define_build_flag(default_openssl); +#endif + + return CONTINUE; +} + + ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, /*OUT*/ bool* print_program_ast, /*OUT*/ bool* print_package_ast) @@ -230,6 +311,10 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, *print_program_ast = false; *print_package_ast = false; + exit_code = special_opt_processing(opt); + if(exit_code != CONTINUE) + return exit_code; + while((id = ponyint_opt_next(s)) != -1) { switch(id) @@ -242,7 +327,14 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, usage(); return EXIT_0; case OPT_DEBUG: opt->release = false; break; - case OPT_BUILDFLAG: define_build_flag(s->arg_val); break; + case OPT_BUILDFLAG: + if (validate_openssl_flag(s->arg_val)) + { // User wants to add an openssl_flag, + // remove any existing openssl_flags. + remove_build_flags(valid_openssl_flags); + } + define_build_flag(s->arg_val); + break; case OPT_STRIP: opt->strip_debug = true; break; case OPT_PATHS: package_add_paths(s->arg_val, opt); break; case OPT_OUTPUT: opt->output = s->arg_val; break; diff --git a/src/libponyc/pkg/buildflagset.c b/src/libponyc/pkg/buildflagset.c index 9b2619c292..eeb3a320ca 100644 --- a/src/libponyc/pkg/buildflagset.c +++ b/src/libponyc/pkg/buildflagset.c @@ -534,6 +534,35 @@ bool define_build_flag(const char* name) } +bool remove_build_flags(const char* flags[]) +{ + pony_assert(flags != NULL); + + if(_user_flags == NULL) + { + // Initialise flags table. + _user_flags = POOL_ALLOC(flagtab_t); + flagtab_init(_user_flags, 8); + } + + size_t removed = 0; + for(const char** next = flags; *next != NULL; next += 1) + { + flag_t f1 = {stringtab(*next), false}; + size_t index = HASHMAP_UNKNOWN; + flag_t* f2 = flagtab_get(_user_flags, &f1, &index); + + if(f2 != NULL) + { // Found one, remove it + removed += 1; + flagtab_removeindex(_user_flags, index); + } + } + + return removed > 0; +} + + bool is_build_flag_defined(const char* name) { pony_assert(name != NULL); diff --git a/src/libponyc/pkg/buildflagset.h b/src/libponyc/pkg/buildflagset.h index f3a22839cb..4b2072b32d 100644 --- a/src/libponyc/pkg/buildflagset.h +++ b/src/libponyc/pkg/buildflagset.h @@ -86,6 +86,10 @@ bool define_build_flag(const char* name); // Report whether the given user build flag is defined. bool is_build_flag_defined(const char* name); +// Remove all flags in the null terminated list +// Returns: true if one or more of the flags were removed +bool remove_build_flags(const char* flags[]); + PONY_EXTERN_C_END #endif diff --git a/src/ponyc/main.c b/src/ponyc/main.c index 2dc8f03462..fb983802b2 100644 --- a/src/ponyc/main.c +++ b/src/ponyc/main.c @@ -87,16 +87,6 @@ int main(int argc, char* argv[]) opt_state_t s; ponyint_opt_init(ponyc_opt_std_args(), &s, &argc, argv); -#if defined(PONY_DEFAULT_PIC) - opt.pic = true; -#endif - -#if defined(USE_SCHEDULER_SCALING_PTHREADS) - // Defined "scheduler_scaling_pthreads" so that SIGUSR2 is made available for - // use by the signals package when not using signals for scheduler scaling - define_build_flag("scheduler_scaling_pthreads"); -#endif - exit_code = ponyc_opt_process(&s, &opt, &print_program_ast, &print_package_ast); if(exit_code == EXIT_255) From 3e31945a4fdf4ff9e409a0852ea71d3bfb226c68 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Fri, 12 Jan 2018 10:07:07 -0800 Subject: [PATCH 3/8] Change validation of openssl flags Now openssl is validated in ponyc_opt_process and in the Makefile making it more likely to catch typos. --- Makefile | 12 ++++++- src/libponyc/options/options.c | 58 ++++++++++++---------------------- 2 files changed, 31 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index ac1d611731..099bbf5e98 100644 --- a/Makefile +++ b/Makefile @@ -299,7 +299,17 @@ ifdef default_openssl endif ifneq (,$(OPENSSL)) - $(warning targeting openssl $(OPENSSL)) + ifeq ("-Dopenssl_0.9.0","$(OPENSSL)") + OPENSSL_VALID:=ok + endif + ifeq ("-Dopenssl_1.1.0","$(OPENSSL)") + OPENSSL_VALID:=ok + endif + ifeq (ok,$(OPENSSL_VALID)) + $(warning targeting openssl $(OPENSSL)) + else + $(error OPENSSL=$(OPENSSL) is invalid, expecting one of -Dopenssl_0.9.0 or -Dopenssl_1.1.0) + endif endif makefile_abs_path := $(realpath $(lastword $(MAKEFILE_LIST))) diff --git a/src/libponyc/options/options.c b/src/libponyc/options/options.c index c0ffb701d3..9fc86d873c 100644 --- a/src/libponyc/options/options.c +++ b/src/libponyc/options/options.c @@ -223,21 +223,21 @@ static void usage(void) ); } +#define OPENSSL_LEADER "openssl_" static const char* valid_openssl_flags[] = - { "openssl_1.1.0", "openssl_0.9.0", NULL }; + { OPENSSL_LEADER "1.1.0", OPENSSL_LEADER "0.9.0", NULL }; -static const char** get_valid_openssl_flags() +static bool is_openssl_flag(const char* name) { - return valid_openssl_flags; + return 0 == strncmp(OPENSSL_LEADER, name, strlen(OPENSSL_LEADER)); } - static bool validate_openssl_flag(const char* name) { - for (const char** next = valid_openssl_flags; *next != NULL; next++) + for(const char** next = valid_openssl_flags; *next != NULL; next++) { - if (0 == strcmp(*next, name)) + if(0 == strcmp(*next, name)) return true; } return false; @@ -252,7 +252,6 @@ static ponyc_opt_process_t special_opt_processing(pass_opt_t *opt) { // Suppress compiler errors due to conditional compilation MAYBE_UNUSED(opt); - MAYBE_UNUSED((void*)get_valid_openssl_flags); #if defined(PONY_DEFAULT_PIC) #if (PONY_DEFAULT_PIC == true) || (PONY_DEFAULT_PIC == false) @@ -269,33 +268,7 @@ static ponyc_opt_process_t special_opt_processing(pass_opt_t *opt) #endif #if defined(PONY_DEFAULT_OPENSSL) - static char default_openssl[100]; - int n = snprintf(default_openssl, sizeof(default_openssl), "%s", - PONY_DEFAULT_OPENSSL); - if (n < 0) - { - printf("Error: %s\n", strerror(errno)); - return EXIT_255; - } - if ((size_t)n >= sizeof(default_openssl)) - { - printf("Error: PONY_DEFAULT_OPENSSL=\"%s\" and is %zu characters long" - ", maximum len=%zu\n", PONY_DEFAULT_OPENSSL, - strlen(PONY_DEFAULT_OPENSSL), sizeof(default_openssl)-1); - return EXIT_255; - } - if (!validate_openssl_flag(default_openssl)) - { - printf("Error: PONY_DEFAULT_OPENSSL=\"%s\" and should be one of:\n", - default_openssl); - for (const char** next = get_valid_openssl_flags(); *next != NULL; next++) - { - printf(" %s\n", *next); - } - return EXIT_255; - } - - define_build_flag(default_openssl); + define_build_flag(PONY_DEFAULT_OPENSSL); #endif return CONTINUE; @@ -328,10 +301,19 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, return EXIT_0; case OPT_DEBUG: opt->release = false; break; case OPT_BUILDFLAG: - if (validate_openssl_flag(s->arg_val)) - { // User wants to add an openssl_flag, - // remove any existing openssl_flags. - remove_build_flags(valid_openssl_flags); + if(is_openssl_flag(s->arg_val)) + { + if(validate_openssl_flag(s->arg_val)) + { // User wants to add an openssl_flag, + // remove any existing openssl_flags. + remove_build_flags(valid_openssl_flags); + } else { + printf("Error: %s is invalid openssl flag, expecting one of:\n", + s->arg_val); + for(const char** next=valid_openssl_flags; *next != NULL; next++) + printf(" %s\n", *next); + return EXIT_255; + } } define_build_flag(s->arg_val); break; From 47c588896f6d501f96a95a8890a60552959d672d Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Fri, 12 Jan 2018 10:00:44 -0800 Subject: [PATCH 4/8] Simplify remove_build_flags Dipin made a good suggestion to use flagtab_remove instead of flagtab_get and flagtab_removeindex. --- src/libponyc/pkg/buildflagset.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/libponyc/pkg/buildflagset.c b/src/libponyc/pkg/buildflagset.c index eeb3a320ca..7cd9ae4f10 100644 --- a/src/libponyc/pkg/buildflagset.c +++ b/src/libponyc/pkg/buildflagset.c @@ -549,14 +549,8 @@ bool remove_build_flags(const char* flags[]) for(const char** next = flags; *next != NULL; next += 1) { flag_t f1 = {stringtab(*next), false}; - size_t index = HASHMAP_UNKNOWN; - flag_t* f2 = flagtab_get(_user_flags, &f1, &index); - - if(f2 != NULL) - { // Found one, remove it + if(flagtab_remove(_user_flags, &f1) != NULL) removed += 1; - flagtab_removeindex(_user_flags, index); - } } return removed > 0; From 506765dce1583c67a1c3e4284eb1700f24dfbaac Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Fri, 12 Jan 2018 20:14:36 -0800 Subject: [PATCH 5/8] Changes from Dipin's code review. Improve the error reporting in the Makefile for default_openssl and OPENSSL. Fix a memory leak when removing a build flag. --- Makefile | 6 +++++- src/libponyc/pkg/buildflagset.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 099bbf5e98..33fc0eea3d 100644 --- a/Makefile +++ b/Makefile @@ -308,7 +308,11 @@ ifneq (,$(OPENSSL)) ifeq (ok,$(OPENSSL_VALID)) $(warning targeting openssl $(OPENSSL)) else - $(error OPENSSL=$(OPENSSL) is invalid, expecting one of -Dopenssl_0.9.0 or -Dopenssl_1.1.0) + ifdef default_openssl + $(error default_openssl=$(default_openssl) is invalid, expecting one of openssl_0.9.0 or openssl_1.1.0) + else + $(error OPENSSL=$(OPENSSL) is invalid, expecting one of -Dopenssl_0.9.0 or -Dopenssl_1.1.0) + endif endif endif diff --git a/src/libponyc/pkg/buildflagset.c b/src/libponyc/pkg/buildflagset.c index 7cd9ae4f10..7d313ea4fb 100644 --- a/src/libponyc/pkg/buildflagset.c +++ b/src/libponyc/pkg/buildflagset.c @@ -549,8 +549,12 @@ bool remove_build_flags(const char* flags[]) for(const char** next = flags; *next != NULL; next += 1) { flag_t f1 = {stringtab(*next), false}; - if(flagtab_remove(_user_flags, &f1) != NULL) + flag_t* found = flagtab_remove(_user_flags, &f1); + if(found != NULL) + { + flag_free(found); removed += 1; + } } return removed > 0; From e39489697a660ee34bf081f97fed11316b08ef67 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Sat, 13 Jan 2018 09:09:51 -0800 Subject: [PATCH 6/8] Remove OPENSSL After sleeping on the discussion with Dipin and realizing that as I had it coded OPENSSL and default_openssl were mutually exclusive because default_openssl was overwriting OPENSSL, I think its simplest to just remove OPENSSL. --- Makefile | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 33fc0eea3d..d3d5cf9a4e 100644 --- a/Makefile +++ b/Makefile @@ -292,28 +292,20 @@ ifeq ($(runtime-bitcode),yes) endif endif -# default OPENSSL version +# Set default openssl version ifdef default_openssl - BUILD_FLAGS += -DPONY_DEFAULT_OPENSSL=\"$(default_openssl)\" - OPENSSL=-D$(default_openssl) -endif - -ifneq (,$(OPENSSL)) - ifeq ("-Dopenssl_0.9.0","$(OPENSSL)") - OPENSSL_VALID:=ok + ifeq ("openssl_0.9.0","$(default_openssl)") + default_openssl_valid:=ok endif - ifeq ("-Dopenssl_1.1.0","$(OPENSSL)") - OPENSSL_VALID:=ok + ifeq ("openssl_1.1.0","$(default_openssl)") + default_openssl_valid:=ok endif - ifeq (ok,$(OPENSSL_VALID)) - $(warning targeting openssl $(OPENSSL)) + ifeq (ok,$(default_openssl_valid)) + $(warning default_openssl is $(default_openssl)) else - ifdef default_openssl - $(error default_openssl=$(default_openssl) is invalid, expecting one of openssl_0.9.0 or openssl_1.1.0) - else - $(error OPENSSL=$(OPENSSL) is invalid, expecting one of -Dopenssl_0.9.0 or -Dopenssl_1.1.0) - endif + $(error default_openssl=$(default_openssl) is invalid, expecting one of openssl_0.9.0 or openssl_1.1.0) endif + BUILD_FLAGS += -DPONY_DEFAULT_OPENSSL=\"$(default_openssl)\" endif makefile_abs_path := $(realpath $(lastword $(MAKEFILE_LIST))) @@ -883,10 +875,10 @@ benchmark: all @$(PONY_BUILD_DIR)/libponyrt.benchmarks stdlib-debug: all - $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d --checktree --verify packages/stdlib + $(PONY_BUILD_DIR)/ponyc -d --checktree --verify packages/stdlib stdlib: all - $(PONY_BUILD_DIR)/ponyc $(OPENSSL) --checktree --verify packages/stdlib + $(PONY_BUILD_DIR)/ponyc --checktree --verify packages/stdlib test-stdlib-debug: stdlib-debug ./stdlib --sequential @@ -897,12 +889,12 @@ test-stdlib: stdlib test: all @$(PONY_BUILD_DIR)/libponyc.tests @$(PONY_BUILD_DIR)/libponyrt.tests - @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib test-examples: all - @PONYPATH=. $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify examples + @PONYPATH=. $(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify examples @./examples1 @rm examples1 @@ -910,21 +902,21 @@ test-ci: all @$(PONY_BUILD_DIR)/ponyc --version @$(PONY_BUILD_DIR)/libponyc.tests @$(PONY_BUILD_DIR)/libponyrt.tests - @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib - @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) --checktree --verify packages/stdlib + @$(PONY_BUILD_DIR)/ponyc --checktree --verify packages/stdlib @./stdlib --sequential @rm stdlib - @PONYPATH=. $(PONY_BUILD_DIR)/ponyc $(OPENSSL) -d -s --checktree --verify examples + @PONYPATH=. $(PONY_BUILD_DIR)/ponyc -d -s --checktree --verify examples @./examples1 @rm examples1 - @$(PONY_BUILD_DIR)/ponyc $(OPENSSL) --antlr > pony.g.new + @$(PONY_BUILD_DIR)/ponyc --antlr > pony.g.new @diff pony.g pony.g.new @rm pony.g.new docs: all - $(SILENT)$(PONY_BUILD_DIR)/ponyc $(OPENSSL) packages/stdlib --docs --pass expr + $(SILENT)$(PONY_BUILD_DIR)/ponyc packages/stdlib --docs --pass expr $(SILENT)cp .docs/extra.js stdlib-docs/docs/ docs-online: docs From d6f651a563c5f8672b4ff10f145000631f812458 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Sat, 13 Jan 2018 09:59:05 -0800 Subject: [PATCH 7/8] Cleanup default pic and openssl - Allow default_pic to be true or false and report an error in the Makefile if it isn't. - Add openssl to ponyc usage - Print pic and openssl defaults when printing version: $ ./build/release/ponyc --version 0.21.2-78fc1a87 [release] compiled with: llvm 5.0.1 -- cc (GCC) 7.2.1 20171224 Defaults: pic=true openssl=openssl_1.1.0 --- Makefile | 14 ++++++++++---- src/libponyc/options/options.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index d3d5cf9a4e..7dc443a3b9 100644 --- a/Makefile +++ b/Makefile @@ -507,11 +507,17 @@ ifeq ($(OSTYPE), linux) libponyrt-pic.buildoptions-ll += -relocation-model=pic endif -# default enable PIC compiling if requested +# Set default PIC for compiling if requested ifdef default_pic - libponyrt.buildoptions += -fpic - libponyrt.buildoptions-ll += -relocation-model=pic - BUILD_FLAGS += -DPONY_DEFAULT_PIC=true + ifeq (true,$(default_pic)) + libponyrt.buildoptions += -fpic + libponyrt.buildoptions-ll += -relocation-model=pic + BUILD_FLAGS += -DPONY_DEFAULT_PIC=true + else + ifneq (false,$(default_pic)) + $(error default_pic must be true or false) + endif + endif endif # target specific disabling of build options diff --git a/src/libponyc/options/options.c b/src/libponyc/options/options.c index 9fc86d873c..68516c7846 100644 --- a/src/libponyc/options/options.c +++ b/src/libponyc/options/options.c @@ -18,6 +18,11 @@ #define MAYBE_UNUSED(x) (void)x +#if !defined(PONY_DEFAULT_OPENSSL) +// This default value is defined in packages/crypto and packages/net/ssl +#define PONY_DEFAULT_OPENSSL "openssl_0.9.0" +#endif + enum { OPT_VERSION, @@ -153,6 +158,9 @@ static void usage(void) " =name Default is the host architecture.\n" " --linker Set the linker command to use.\n" " =name Default is the compiler used to compile ponyc.\n" + " --define, -D Define which openssl version to use default is " PONY_DEFAULT_OPENSSL "\n" + " =openssl_1.1.0\n" + " =openssl_0.9.0\n" , "Debugging options:\n" " --verbose, -V Verbosity level.\n" @@ -267,9 +275,7 @@ static ponyc_opt_process_t special_opt_processing(pass_opt_t *opt) define_build_flag("scheduler_scaling_pthreads"); #endif -#if defined(PONY_DEFAULT_OPENSSL) define_build_flag(PONY_DEFAULT_OPENSSL); -#endif return CONTINUE; } @@ -294,6 +300,8 @@ ponyc_opt_process_t ponyc_opt_process(opt_state_t* s, pass_opt_t* opt, { case OPT_VERSION: printf("%s\n", PONY_VERSION_STR); + printf("Defaults: pic=%s openssl=%s\n", opt->pic ? "true" : "false", + PONY_DEFAULT_OPENSSL); return EXIT_0; case OPT_HELP: From b586b41cb6b4a66f2b19c907b33016865f9d7112 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Sun, 14 Jan 2018 18:04:11 -0800 Subject: [PATCH 8/8] Update README.md Remove the mention of the ponyc-rpm workaround Remove mention of pic errors and instead have command line provide default_pic and default_openssl. --- README.md | 55 ++++++------------------------------------------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 8b86b64c82..99c4328eda 100644 --- a/README.md +++ b/README.md @@ -180,38 +180,6 @@ sudo apt-get update sudo apt-get -V install ponyc ``` -## Arch Linux - -Currently the ponyc package in Arch does not work because -Arch is using LLVM 5 and ponyc requires LLVM 3.9. - -There is experimental support for building from source with LLVM 5.0.0, -but this may cause decreased performance or crashes in generated -applications. - -Using [Docker](#using-docker) is one choice, another is to -use [ponyc-rpm](https://aur.archlinux.org/packages/ponyc-rpm/) - -### ponyc-rpm -#### Prerequisites: `git` and `rpmextract` -``` -sudo pacman -Syu git rpmextract -``` -#### Instructions: -Clone the repo, change directory to the repo, run `makepkg -si` -or use your favorite AUR package manager. -``` -git clone https://aur.archlinux.org/ponyc-rpm.git -cd ponyc-rpm -makepkg -si -``` - -#### Ponyc Usage -You must pass the `--pic` parameter to ponyc on Arch Linux -``` -ponyc --pic -``` - ## Gentoo Linux ```bash @@ -296,30 +264,19 @@ git clone git://github.com/ponylang/ponyc ### Arch -``` -pacman -S llvm make ncurses openssl pcre2 zlib -``` - -To build ponyc and compile helloworld: +Install pony dependencies: -```bash -make -./build/release/ponyc examples/helloworld ``` - -If you get errors like - -```bash -/usr/bin/ld.gold: error: ./fb.o: requires dynamic R_X86_64_32 reloc against - 'Array_String_val_Trace' which may overflow at runtime; recompile with -fPIC +pacman -S llvm make ncurses openssl pcre2 zlib ``` -You need to rebuild `ponyc` with `default_pic=true` +To build ponyc and compile and helloworld: ```bash -make clean -make default_pic=true +cd ~/ponyc/ +make default_pic=true default_openssl='openssl_1.1.0' ./build/release/ponyc examples/helloworld +./helloworld ``` ### Debian Jessie