-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make opensslconf.h include depending on target archs #1377
Conversation
@shigeki Can you add a Makefile target that regenerates the config files? Doesn't have to be the top-level Makefile, adding a new one in deps/openssl is fine too. |
@bnoordhuis +1 |
#elif defined(_WIN32) && defined(_M_X64) | ||
#include "./archs/VC-WIN64A/opensslconf.h" | ||
#elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) | ||
#include "./archs/BSD-x86/opensslconf.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear, the uppercase directory name is generated by openssl's Configure script?
Style nit: can you write this as #include
or # include
? This indent style isn't used anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The directory name is the same as the one specified in Configure script. I will change the style to put the hash bangs at the head of line.
@bnoordhuis Adding Makefile is a good idea. I will try it. |
I've just updated this to add Makefile that can re-generate files of opensslconf.h for all supported targets and apply fixes to linux-x32, darwin64-x86_64-cc and WIN. But |
PERL = perl | ||
CONFIGURE = ./Configure | ||
CONFIGOPT = no-shared no-symlinks | ||
ARCS = BSD-x86 BSD-x86_64 VC-WIN32 VC-WIN64A darwin64-x86_64-cc darwin-i386-cc linux-armv4 linux-elf linux-x86_64 solaris-x86-gcc solaris64-x86_64-gcc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/ARCS/ARCHS/ maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I will fix this.
Yay, looking good to me! |
I have to make spell checks for my all commits. |
@rm ../openssl/tools/c_rehash.bak | ||
|
||
clean: | ||
find archs -name opensslconf.h -exec rm "{}" \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because you're already using perl, would it be an idea to replace the sed one-liners with perl one-liners? That prevents GNU sed vs. BSD sed compatibility issues. You also don't have to escape so much because you can just do perl -i -pe 's!foo/bar!quux/qunc!g'
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and would it be possible to wrap the long lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I will try it.
9dd9f17
to
7d1d2b8
Compare
@bnoordhuis I've just update New CI of https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/474/ seems to be fine except new failures of smartos64 and win2008 but they are not related. It's great arm tests are getting better. Thanks. |
There's a small typo in the last commit log (s/archtectures/architectures/) but apart from that LGTM. Nice work. |
In OpenSSL, opensslconf.h was generated by Configure script with specifying a target argument, where it includes several defines that depend on OS and architecture platform. In iojs, we statically mapped --dest-os and --dest-cpu options in configure to the target of Configure in OpenSSL and make `deps/openssl/conf/openssconf.h` so as to include each file according to its target by checking pre-defined compiler macros. Included opnesslconf.h files for supported target architectures can be generated by `Makefile` and stored under `archs/{target}/opensslconf.h`. The Makefile alos fixes several defines to meet iojs build requirements. Here is a map table of configure options in iojs, target arch of Configure in OpenSSL and CI support. | --dest-os | --dest-cpu | OpenSSL target arch | CI | | --------- | ---------- | -------------------- | --- | | linux | ia32 | linux-elf | o | | linux | x32 | patched linux-x86_64 | - | | linux | x64 | linux-x86_64 | o | | linux | arm | linux-armv4 | o | | linux | arm64 | N/A | - | | mac | ia32 | darwin-i386-cc | o | | mac | x64 | darwin64-x86-cc | o | | win | ia32 | VC-WIN32 | - | | win | x64 | VC-WIN64A | o | | solaris | ia32 | solaris-x86-gcc | o | | solaris | x64 | solaris64-x86_64-gcc | o | | freebsd | ia32 | BSD-x86 | o | | freebsd | x64 | BSD-x86_64 | o | | openbsd | ia32 | BSD-x86 | - | | openbsd | x64 | BSD-x86_64 | - | | others | others | linux-elf | - | --dest-os and --dest-cpu are mapped to pre-defined macros. | --dest-os | pre-defined macro | | ------------------ | ------------------------- | | win | _WIN32 | | win(64bit) | _WIN64 | | mac | __APPLE__ && __MACH__ | | solaris | __sun | | freebsd | __FreeBSD__ | | openbsd | __OpenBSD__ | | linux (not andorid)| __linux__ && !__ANDROID__ | | android | __ANDROID__ | | --dest-cpu | pre-defined macro | | ---------- | ----------------- | | arm | __arm__ | | arm64 | __aarch64__ | | ia32 | __i386__ | | ia32(win) | _M_IX86 | | mips | __mips__ | | mipsel | __MIPSEL__ | | x32 | __ILP32__ | | x64 | __x86_64__ | | x64(win) | _M_X64 | These are the list which is not implemented yet. | --dest-os | --dest-cpu | OpenSSL target arch | CI | | --------- | ---------- | -------------------- | --- | | linux | mips | linux-mips32,linux-mips64,linux64-mips64? | --- | | linux | mipsel | ? | --- | | android | ia32 | android-x86 | --- | | android | arm | android-armv7 | --- | | android | mips | android-mips | --- | | android | mipsel | ? | --- | Supported target arch list in OpenSSL can be obtained by typing `deps/openssl/openssl/Configure LIST`. This also contains to add two new defines for all platform in the bottom for GOST and Padlock engines are not included in iojs.
This Makefile executes ../openssl/Configure {target} and copy generated `../openssl/crypto/opensslconf.h` into `archs/{target}/opensslconf.h`. with the target list that is defined in ARCS. Several files are copied for backup and cleared so as not to change the files in `../openssl`. This also applies four fixes as below by using perl script so as to meet iojs build requirements. - all architectures Remove define of OPENSSL_CPUID_OBJ because it is defined in openssl.gypi so as to avoid build error with --openssl-no-asm - VC-WIN32 and VC-WIN64A OPENSSL_NO_DYNAMIC_ENGINE is needed for building static library. OPENSSL_NO_CAPIENG is needed to avoid build errors on Win. See the comments in `deps/openssl/openssl/engines/e_capi.c` for detail. - linux-x32 This fix was made by comparing define values of opensslconf.h which was generated `Configure linux-x32' in openssl-1.0.2a - darwin64-x86_64-cc The current openssl release does not use RC4 asm since it explicitly specified as `$asm=~s/rc4\-[^:]+//;` in https://github.com/openssl/openssl/blob/OpenSSL_1_0_1-stable/Configure#L584 But iojs has used RC4 asm on MacOS for long time. Fix type of RC4_INT into `unsigned int` in opensslconf.h of darwin64-x86_64-cc to work on the RC4 asm.
In OpenSSL, opensslconf.h was generated by Configure script with specifying a target argument, where it includes several defines that depend on OS and architecture platform. In iojs, we statically mapped --dest-os and --dest-cpu options in configure to the target of Configure in OpenSSL and make `deps/openssl/conf/openssconf.h` so as to include each file according to its target by checking pre-defined compiler macros. Included opnesslconf.h files for supported target architectures can be generated by `Makefile` and stored under `archs/{target}/opensslconf.h`. The Makefile alos fixes several defines to meet iojs build requirements. Here is a map table of configure options in iojs, target arch of Configure in OpenSSL and CI support. | --dest-os | --dest-cpu | OpenSSL target arch | CI | | --------- | ---------- | -------------------- | --- | | linux | ia32 | linux-elf | o | | linux | x32 | patched linux-x86_64 | - | | linux | x64 | linux-x86_64 | o | | linux | arm | linux-armv4 | o | | linux | arm64 | N/A | - | | mac | ia32 | darwin-i386-cc | o | | mac | x64 | darwin64-x86-cc | o | | win | ia32 | VC-WIN32 | - | | win | x64 | VC-WIN64A | o | | solaris | ia32 | solaris-x86-gcc | o | | solaris | x64 | solaris64-x86_64-gcc | o | | freebsd | ia32 | BSD-x86 | o | | freebsd | x64 | BSD-x86_64 | o | | openbsd | ia32 | BSD-x86 | - | | openbsd | x64 | BSD-x86_64 | - | | others | others | linux-elf | - | --dest-os and --dest-cpu are mapped to pre-defined macros. | --dest-os | pre-defined macro | | ------------------ | ------------------------- | | win | _WIN32 | | win(64bit) | _WIN64 | | mac | __APPLE__ && __MACH__ | | solaris | __sun | | freebsd | __FreeBSD__ | | openbsd | __OpenBSD__ | | linux (not andorid)| __linux__ && !__ANDROID__ | | android | __ANDROID__ | | --dest-cpu | pre-defined macro | | ---------- | ----------------- | | arm | __arm__ | | arm64 | __aarch64__ | | ia32 | __i386__ | | ia32(win) | _M_IX86 | | mips | __mips__ | | mipsel | __MIPSEL__ | | x32 | __ILP32__ | | x64 | __x86_64__ | | x64(win) | _M_X64 | These are the list which is not implemented yet. | --dest-os | --dest-cpu | OpenSSL target arch | CI | | --------- | ---------- | -------------------- | --- | | linux | mips | linux-mips32,linux-mips64,linux64-mips64? | --- | | linux | mipsel | ? | --- | | android | ia32 | android-x86 | --- | | android | arm | android-armv7 | --- | | android | mips | android-mips | --- | | android | mipsel | ? | --- | Supported target arch list in OpenSSL can be obtained by typing `deps/openssl/openssl/Configure LIST`. This also contains to add two new defines for all platform in the bottom for GOST and Padlock engines are not included in iojs. PR-URL: #1377 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This Makefile executes ../openssl/Configure {target} and copy generated `../openssl/crypto/opensslconf.h` into `archs/{target}/opensslconf.h`. with the target list that is defined in ARCS. Several files are copied for backup and cleared so as not to change the files in `../openssl`. This also applies four fixes as below by using perl script so as to meet iojs build requirements. - all architectures Remove define of OPENSSL_CPUID_OBJ because it is defined in openssl.gypi so as to avoid build error with --openssl-no-asm - VC-WIN32 and VC-WIN64A OPENSSL_NO_DYNAMIC_ENGINE is needed for building static library. OPENSSL_NO_CAPIENG is needed to avoid build errors on Win. See the comments in `deps/openssl/openssl/engines/e_capi.c` for detail. - linux-x32 This fix was made by comparing define values of opensslconf.h which was generated `Configure linux-x32' in openssl-1.0.2a - darwin64-x86_64-cc The current openssl release does not use RC4 asm since it explicitly specified as `$asm=~s/rc4\-[^:]+//;` in https://github.com/openssl/openssl/blob/OpenSSL_1_0_1-stable/Configure#L584 But iojs has used RC4 asm on MacOS for long time. Fix type of RC4_INT into `unsigned int` in opensslconf.h of darwin64-x86_64-cc to work on the RC4 asm. PR-URL: #1377 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: #1377 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
PR-URL: #1377 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
This is a proposal to change
deps/openssl/conf/opensslconf.h
before upgrading 1.0.2a.@bnoordhuis @indutny I would like to have your feedback.
The current
deps/openssl/conf/opensslconf.h
is very hard to maintain with increasing supporting OS and CPU because it is generated by Configure script with specifying a target argument, where it includes sevral defines that depend on OS and architecture platform. Seehttps://github.com/shigeki/io.js/blob/old_upgrade_openssl102a/deps/openssl/doc/openssl_conf.pdf
is a table at a glance.
A new approach here is that we statically mapped
--dest-os
and--dest-cpu
options in configure to the target of Configure in OpenSSL. The opensslconf.h in each target was created in advance by typingdeps/openssl/openssl/Configure {target}
and copied intodeps/openssl/conf/archs/{target}/opensslconf.h
. After that we apply the fix of opensslconf.h according to iojs requirements.We change
deps/openssl/conf/openssconf.h
so as to include each file according to its target by checking pre-defined compiler macros.Here is a map table of configure options in iojs, target arch of Configure in OpenSSL and CI check.
--dest-os and --dest-cpu are mapped to pre-defined macros.
These are the list which is not implemented yet.
Supported target arch list in OpenSSL can be obtained by typing
deps/openssl/openssl/Configure LIST
.The CI result is fine with this change as
https://jenkins-iojs.nodesource.com/job/iojs+any-pr+multi/464/
If this approach is not accepted, I will be back work on it as in shigeki@2d5ca2a that was the same way as we did in the past.