Skip to content

Commit f291205

Browse files
committed
Added CONTRIBUTING.md with instructions for how to upgrade
1 parent ed3f9d1 commit f291205

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

CONTRIBUTING.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Summary
2+
3+
This instruction describes how to pragmatically upgrade the openssl d-bindings
4+
to match the C-headers version, in this case current version is 1.1.0h.
5+
6+
## Steps
7+
8+
### Preparation
9+
10+
1. Get d-step tool with:
11+
```
12+
curl \
13+
--location \
14+
https://github.com/jacob-carlborg/dstep/releases/download/v1.0.0/dstep-1.0.0-linux-x86_64.tar.xz \
15+
| tar -x --xz --location /usr/local/bin
16+
```
17+
See more @ <https://github.com/jacob-carlborg/dstep/releases>.
18+
2. Clone openssl with `git clone https://github.com/openssl/openssl` and
19+
checkout correct tag, example `cd openssl && git checkout OpenSSL_1_1_0h`.
20+
3. Headers with suffix ".h.in" need to be parsed to .h before generation,
21+
Configure openssl with `./configure` and build generated file with
22+
`make build_generated`.
23+
24+
### Check dependencies
25+
26+
A good approach is to convert the files in ascending order for no of
27+
dependencies. Example when converting x509, use order: `x509_vfy.h` which
28+
is used by 1 other file, `x509v3.h` is used by 3 other files, `x509.h`
29+
is used by 11 other files.
30+
31+
```
32+
grep -r 'include <openssl/x509_vfy.h>$' C/
33+
grep -r 'include <openssl/x509v3.h>$' C/
34+
grep -r 'include <openssl/x509.h>$' C/
35+
```
36+
37+
### Generate module from C header
38+
39+
1. Generate d-module from the openssl c-header with
40+
`dstep --space-after-function-name=false -Iinclude/ include/openssl/<file>`. Commit the change.
41+
42+
### Manual patching
43+
44+
Below is a checklist for common known issues which needs manual work:
45+
46+
1. d-step doesn't resolve includes. Translate "import" statements from
47+
`#include` in header-file accordingly, and possible check in the old .d-file
48+
for special cases.
49+
2. Function aliases in C-headers without argument list, example
50+
`#define alias-name function` are generated as enum types. This gives
51+
compilation error similar to "missing argument for parameter #1".
52+
Replace "enum" with "alias" accordingly.
53+
3. Many struct definitions is removed, instead a declaration ia added into
54+
`ossl_typ.d`, Example `grep -r 'struct X509_pubkey_st' C/` shows that struct
55+
definition is removed from `x509.h` and instead a declaration is added in
56+
`ossl_typ.h`. Other types might be removed, check the header-file and adjust
57+
accordingly if the type is missing when compiling.
58+
4. Check the header-file for "ifdef|ifndef", search for "OPENSSL_*" where some
59+
statements has historically been translated into "version" in d-modules.
60+
5. Macros `STACK_OF`, `DEFINE_STACK_OF`: in version 1.1.0h the macro `STACK_OF`
61+
in `safestack.d` has changed. During generation it's properly expanded into
62+
a type prefixed with `stack_st`. Since other dependent modules might not be
63+
uplifted, a declaration sometimes need to be inserted to make it
64+
compile. It will result in "type missing "stack_st_...". Check in which
65+
header the macro `DEFINE_STACK_OF(<type>)` is defined in and manually add
66+
`struct stack_st_<type-name>` to make it compile. However these functions
67+
will not work properly during linkage until `safestack.d` is uplifted,
68+
see macro `DEFINE_STACK_OF` in safestack.h.
69+

0 commit comments

Comments
 (0)