Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Disable SAFESEH in node.gyp when building with vs 2012 #4242

Closed
peters opened this issue Nov 5, 2012 · 10 comments
Closed

Disable SAFESEH in node.gyp when building with vs 2012 #4242

peters opened this issue Nov 5, 2012 · 10 comments

Comments

@peters
Copy link

peters commented Nov 5, 2012

http://msdn.microsoft.com/en-us/library/9a89h429(v=vs.80).aspx

Unable to build the Debug release without disabling SAFESEH.

I'm not a windows guy, so this might be a bad thing for all i know, but if not it could be added to gyp:

http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vcprojectengine.vclibrariantool.additionaloptions(v=vs.80).aspx

@piscisaureus
Copy link

We're building it with vs2010, so I don't have a copy vs2012. How does it fail? Can you paste the build output?

@peters
Copy link
Author

peters commented Nov 5, 2012

1>------ Skipped Build: Project: http_parser, Configuration: Debug Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Build started: Project: node, Configuration: Debug Win32 ------
2>openssl.lib(x86cpuid.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(x86.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(aes-586.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(des-586.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(rc4-586.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(bf-686.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(cast-586.obj) : error LNK2026: module unsafe for SAFESEH image.
2>openssl.lib(wp-mmx.obj) : error LNK2026: module unsafe for SAFESEH image.
2>     Creating library C:\Users\peters\Documents\GitHub\node\Debug\node.lib and object C:\Users\peters\Documents\GitHub\node\Debug\node.exp
2>C:\Users\peters\Documents\GitHub\node\Debug\node.exe : fatal error LNK1281: Unable to generate SAFESEH image.
========== Build: 0 succeeded, 1 failed, 14 up-to-date, 1 skipped ==========

@tjfontaine
Copy link

I am similarly getting this, but not only on debug but also release

snippet

src\timer_wrap.cc(153): warning C4244: 'argument' : conversion from 'int64_t' to 'int32_t', possible loss of data [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
src\node_crypto.cc(599): warning C4244: 'argument' : conversion from 'int64_t' to 'long', possible loss of data [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
RC : warning RC4005: 'PLATFORM' : redefinition [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]

RC : warning RC4005: 'PLATFORM' : redefinition [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]

RC : warning RC4005: 'PLATFORM' : redefinition [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]

     Creating library g:\jenkins\workspace\nodejs-oneoff\Release\node.lib and object g:\jenkins\workspace\nodejs-oneoff\Release\node.exp
  Generating code
  Finished generating code
openssl.lib(x86cpuid.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(x86.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(aes-586.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(rc4-586.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(cmll-x86.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(des-586.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(bf-686.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(cast-586.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
openssl.lib(wp-mmx.obj) : error LNK2026: module unsafe for SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]
g:\jenkins\workspace\nodejs-oneoff\Release\node.exe : fatal error LNK1281: Unable to generate SAFESEH image. [g:\jenkins\workspace\nodejs-oneoff\node.vcxproj]

full log available http://jenkins.nodejs.org/job/nodejs-oneoff/35/consoleText

@bnoordhuis
Copy link
Member

Does this patch fix it?

diff --git a/common.gypi b/common.gypi
index 9ecfc4d..72138f3 100644
--- a/common.gypi
+++ b/common.gypi
@@ -121,6 +121,7 @@
         'WarningLevel': 3,
         'BufferSecurityCheck': 'true',
         'ExceptionHandling': 1, # /EHsc
+        'ImageHasSafeExceptionHandlers': 0, # /SAFESEH:NO
         'SuppressStartupBanner': 'true',
         'WarnAsError': 'false',
       },

(If not, @piscisaureus or @sblom should look at this.)

@peters
Copy link
Author

peters commented Feb 28, 2013

Yes, that does the job :)

@peters
Copy link
Author

peters commented Mar 22, 2013

@bnoordhuis Just tried building v0.10.1 and safeseh issue is back again.

openssl.lib(x86cpuid.obj) : error LNK2026: module unsafe for SAFESEH image. [C:
\Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(x86.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\User
s\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(aes-586.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\
Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(rc4-586.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\
Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(cmll-x86.obj) : error LNK2026: module unsafe for SAFESEH image. [C:
\Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(des-586.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\
Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(bf-686.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\U
sers\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(cast-586.obj) : error LNK2026: module unsafe for SAFESEH image. [C:
\Users\peters\Documents\GitHub2\node\node.vcxproj]
openssl.lib(wp-mmx.obj) : error LNK2026: module unsafe for SAFESEH image. [C:\U
sers\peters\Documents\GitHub2\node\node.vcxproj]
C:\Users\peters\Documents\GitHub2\node\Release\node.exe : fatal error LNK1281:
Unable to generate SAFESEH image. [C:\Users\peters\Documents\GitHub2\node\node.
vcxproj]

@bnoordhuis
Copy link
Member

/cc @piscisaureus

@piscisaureus
Copy link

@peters Can you try to build with a fresh checkout, or run git clean -fdX? For me, VS didn't pick up the change in assembler flags at first so it didn't reassemble with the changed options.

@pguerrant
Copy link

I'm experiencing the same issue using node v0.10.18 and node-gyp v0.10.10. Does anyone know of a workaround?

@pguerrant
Copy link

@piscisaureus I think I may know what the problem is here - ImageHasSafeExceptionHandlers is a property of the Link Task, not VCCLCompilerTool. I was able to get my addon to compile by adding a Link setting to msbuild_settings in binding.gyp. e.g.:

{
    "targets": [
        {
            "msbuild_settings": {
                "Link": {
                    "ImageHasSafeExceptionHandlers": "false"
                }
            },

            "target_name": "myaddon",
            ...

        }
    ]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants