# nodejs/node

Merged
merged 1 commit into from Jul 5, 2016
+152 −0

## Conversation

Projects
None yet
8 participants
Member

### bnoordhuis commented Apr 19, 2016 • edited

 Add a smoke test for checking that linking to the bundled openssl from an add-on works. CI 1st attempt: https://ci.nodejs.org/job/node-test-pull-request/2315/ CI 2nd attempt: https://ci.nodejs.org/job/node-test-pull-request/2316/ CI 3rd attempt: https://ci.nodejs.org/job/node-test-pull-request/2373/ CI 4th attempt: https://ci.nodejs.org/job/node-test-pull-request/2378/ CI 5th attempt: https://ci.nodejs.org/job/node-test-pull-request/2407/ CI 6th attempt: https://ci.nodejs.org/job/node-test-pull-request/2408/ CI 7th attempt: https://ci.nodejs.org/job/node-test-pull-request/2581/ CI 8th attempt: https://ci.nodejs.org/job/node-test-pull-request/2607/ CI 9th attempt: https://ci.nodejs.org/job/node-test-pull-request/3168/ CI 10th attempt: https://ci.nodejs.org/job/node-test-pull-request/3169/ CI 11th attempt: https://ci.nodejs.org/job/node-test-pull-request/3170/

Closed

Member

### jasnell commented Apr 19, 2016 • edited

 Sadly this failed on windows. :-/ => https://ci.nodejs.org/job/node-test-binary-windows/1795/RUN_SUBSET=1,VS_VERSION=vcbt2015,label=win10/
Member

### bnoordhuis commented Apr 19, 2016

 It's the age-old problem of the windows build not exporting openssl symbols. I'm going to tinker with deps/openssl/openssl/util/mkdef.pl and see if I can make the .def part of the build somehow.
Member

### bnoordhuis commented Apr 23, 2016

 I haven't had much luck on Windows so far. I added a ExportNamedFunctions directive to common.gypi and I see a  in node.vcproj but building the add-on still fails with missing symbol errors: binding.obj : error LNK2001: unresolved external symbol RAND_bytes [c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\addons\openssl-binding\build\binding.vcxproj] binding.obj : error LNK2001: unresolved external symbol RAND_poll [c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\addons\openssl-binding\build\binding.vcxproj] c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\addons\openssl-binding\build\Release\binding.node : fatal error LNK1120: 2 unresolved externals [c:\workspace\node-test-binary-windows\RUN_SUBSET\1\VS_VERSION\vs2015\label\win2012r2\test\addons\openssl-binding\build\binding.vcxproj]  @nodejs/platform-windows Ideas? @nodejs/build Is there a way to extract build artifacts from the buildbots? The node.lib and node.exp files in particular?

Closed

Closed

Closed

Member

### rvagg commented May 10, 2016

 @nodejs/build Is there a way to extract build artifacts from the buildbots? The node.lib and node.exp files in particular? @bnoordhuis what do you need here exactly? You want the build artifacts after the jobs are finished or beforehand? Are you wanting to inspect artifacts to debug the job? If that's what you're after we have to instruct Jenkins what files to grab using globs
Member

### bnoordhuis commented May 10, 2016

 You want the build artifacts after the jobs are finished or beforehand? After. I'd like the node.lib and the node.exp files that are built. The binary itself might come in handy, too.
Member

### joaocgreis commented May 10, 2016

 @bnoordhuis do you want the files to download so you can check them locally or do you want them to be present in the test machines? There is no automated way to get the files from the CI slaves. If you want the files let me know exactly what to build (this PR head?) and I can email them to you. If you want the files on the test machines, you can try https://ci.nodejs.org/job/node-test-commit-windows/ , that builds and tests in the same job. If you can make that work, I'll make it work with the fanned job.
Member

### bnoordhuis commented May 10, 2016

 Thanks, I was hoping I could download the files somewhere, but I'll tweak this PR some more and ping you when I need them.
Member

### bnoordhuis commented May 11, 2016 • edited

 I may have inadvertently broken the Windows CI with my latest update, all the bots are hanging at the "Building add-ons" step now... https://ci.nodejs.org/job/node-test-binary-windows/2077/
Member

### joaocgreis commented May 12, 2016

 @bnoordhuis when that happens, please abort the job, it's no big issue. I tried to build this locally, and node.exe is a DLL.
Member

### bnoordhuis commented May 12, 2016

 You mean it's not an executable but a library? Le sigh, it must be something that gyp is doing. I'm going to try it one more time in case the CI was in a funk yesterday: https://ci.nodejs.org/job/node-test-pull-request/2607/

### kurtextrem commented Jun 13, 2016 • edited

 Any news? This is a blocker for https://github.com/alexhultman/uWebSockets/issues/72
Contributor

### alexhultman commented Jun 20, 2016

 I took a peek at this and it seems to be two things: OpenSSL and zlib. Both of these are missing from the symbol table (dumpbin /EXPORTS node.exe). I ran the vcbuild.bat which generated the VS solution and then I just looked at the project and couldn't really see any reference to any .def file. So I just went to Project -> Properties -> Linker -> Input -> Module Definition File and put the path to the zlib.def file as a test and built the program. Now I get all the zlib functions exported and I can see there are inflate and such functions in node.lib. So maybe you could just focus on generating one .def file with both openssl and zlib functions and just pass that one file as /DEF:filename? V8 and uv are already exported but I couldn't see any .def file so maybe you are using __declspec(dllexport) or something - I don't know but passing the zlib.def worked and I can send you my node.lib and node.exe if you want to compare the symbol table.
Contributor

### alexhultman commented Jul 3, 2016

 What is the status on this? If things get way to complex, wouldn't it be pretty simple to manually run the mkdef perl script offline and commit as one fix .def file? Or just write a new script that just scrapes functions from the documentation. With /DEF:file.def /FORCE:UNRESOLVED it won't fail if the def file contains symbols that are not in the binary, they will be ignored, so even if you configure Node.js in some way it should still work with one single fix .def file.
Contributor

### alexhultman commented Jul 4, 2016

 I just built a node.exe that exports all OpenSSL symbols and runs as an executable. The size is about 700kb larger than normal and RAND_poll is listed when dumpbin / exports. I did not use /FORCE:UNDEFINED, only /DEF. I ended up writing a "script" that exports the symbols from openssl.lib (I couldn't scrape the symbols from the documentation because some of the symbols were just macros and thus not real symbols). I could commit my node.def file and add instructions on how to generate it (including code). Basically I used nm -s openssl.lib and filtered mangled non-C functions out. I also have a dump from dumpbin if you want to see.
Member

### bnoordhuis commented Jul 4, 2016

 I just built a node.exe that exports all OpenSSL symbols My plan was to restrict what we export to just public symbols. Right now we export everything on UNIX platforms.
Contributor

### alexhultman commented Jul 4, 2016

 You could do a combination where you scrape the documentation + limit the symbols to what is in openssl.lib. That way macros are not added and only the documented public symbols are added. I have a tool that can scrape all the public symbols and also limit them to what is in openssl.lib. To get the /DEF option added to the VC++ node project I did this in node.gyp: 'VCLinkerTool': { 'ModuleDefinitionFile': 'node.def' }  As an addition after the 'VCManifestTool' under 'msvs_settings'. It shows up in Visual Studio and I'm building it right now.
Member

### bnoordhuis commented Jul 4, 2016

 OpenSSL maintains a list of public symbols in the .num files. The python script in this pull request turns it into a .def that cl.exe can consume (which worked, last I recall) but it would need to be adapted to produce a link map that UNIX linkers can consume.
Contributor

### alexhultman commented Jul 4, 2016

 Okay that's nice but from what I have read your main problem was getting the Node.js binary as an executable and not a library, etc. With this commit: https://github.com/uWebSockets/node/commit/887ad7e7ba0cd888e7a1de323c139c4f7088091c It compiles and works and produces a node.exe. You just put the node.def in the root directory and run vcbuild.bat. You also need to add zlib symbols to the def file. It just finished building and it worked.
Contributor

### alexhultman commented Jul 4, 2016

 So maybe it would be best to solve it incrementally, for Windows first and then move on to improve the Unix build. The Unix build works while the Windows build does not so it would improve Node.js a lot to solve this in steps rather than wait a long time to get the nicest fix. Perfectionism is the enemy of good 😉

node.gyp
Contributor

### alexhultman commented Jul 4, 2016

 I'm building with your PR now. It generated a nice openssl.def but in the top it says LIBRARY node. According to MSDN this tells the linker to create a DLL. Maybe that is the problem. My def file has no LIBRARY node, just EXPORTS. I will see if this generates a DLL or EXE. If it does, I will try and fix it.

### alexhultman reviewed Jul 4, 2016

tools/mkssldef.py
Contributor

### alexhultman commented Jul 4, 2016

 Yep, this PR builds a DLL. I removed the line "LIBRARY node" from the def file and now it builds an EXE. @bnoordhuis if you remove that line from the python script this PR looks to solve the problem, all the symbols are properly exported.
Member

### bnoordhuis commented Jul 4, 2016

 Okay, let's see what happens with that change applied.
Member

Contributor

### alexhultman commented Jul 4, 2016

 Lol the latest test failed on freebsd 😉
Member

### bnoordhuis commented Jul 4, 2016

 Unrelated flake, fortunately. Barring nays from other reviewers I'll merge this tomorrow.
 build: export openssl symbols on windows 
Export symbols from the bundled openssl for add-ons to link against.

Fixes: nodejs/node-v0.x-archive#4051
PR-URL: #6274
Reviewed-By: James M Snell <jasnell@gmail.com>
 b4d4fd9 

### Fishrock123 added a commit that referenced this pull request Jul 6, 2016

 build: export openssl symbols on windows 
Export symbols from the bundled openssl for add-ons to link against.

Fixes: nodejs/node-v0.x-archive#4051
PR-URL: #6274
Reviewed-By: James M Snell <jasnell@gmail.com>
 15a32dd 

Merged

Contributor

### alexhultman commented Jul 6, 2016

 @bnoordhuis There's a bug in the mkssldef.py script. I'm missing SSL_set_fd and two others. They are present in the ssleay.num file but have a different format of the rightmost column. Most symbols are present now in 6.3.0 though.
Contributor

### alexhultman commented Jul 6, 2016

 This is my output when compiling on Windows with 6.3.0: Server.obj : error LNK2001: unresolved external symbol SSL_CTX_use_PrivateKey_file [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol SSL_set_fd [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol inflateInit2_ [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol deflateInit2_ [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol deflateReset [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol SSL_CTX_use_certificate_chain_file [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol deflateEnd [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] Server.obj : error LNK2001: unresolved external symbol deflate [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] WebSocket.obj : error LNK2001: unresolved external symbol inflateEnd [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] WebSocket.obj : error LNK2001: unresolved external symbol inflate [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] C:\Users\alex\uWebSockets\nodejs\dist\build\Release\uws.node : fatal error LNK1120: 10 unresolved externals [C:\Users\alex\uWebSockets\nodejs\dist\build\uws.vcxproj] 

Closed

Member

### MylesBorins commented Jul 11, 2016

 @bnoordhuis this does not land cleanly. It will require a backport.
Member

### bnoordhuis commented Jul 12, 2016

 #7676 - TBD if it should land.

Closed

Closed

Member

### Fishrock123 commented Aug 8, 2016

 I don't see an actual commit link here so I dug it up: b4d4fd9

Closed

### bnoordhuis added a commit to bnoordhuis/io.js that referenced this pull request Oct 18, 2016

 build: export openssl symbols on windows 
Export symbols from the bundled openssl for add-ons to link against.

Fixes: nodejs/node-v0.x-archive#4051
PR-URL: nodejs#6274
Reviewed-By: James M Snell <jasnell@gmail.com>
 c97d1c2 

### MylesBorins added a commit that referenced this pull request Nov 14, 2016

 build: export openssl symbols on windows 
Export symbols from the bundled openssl for add-ons to link against.

Fixes: nodejs/node-v0.x-archive#4051
PR-URL: #6274
Reviewed-By: James M Snell <jasnell@gmail.com>
 3cefd65 

Merged

Closed

Closed

Open