From 21df26e038c4039150a7978188ecd0b6a5f23d2b Mon Sep 17 00:00:00 2001 From: "John Chen (CLR)" Date: Fri, 5 Aug 2016 16:08:18 -0700 Subject: Modify "crossgen -createpdb" to skip loading clrjit.dll (#6607) The -JITPath option doesn't work properly when CrossGen is used to create a PDB file (issue #6607). Since clrjit.dll isn't really needed for creating PDB files, the issue is fixed by modifying CrossGen to skip loading clrjit.dll when -createpdb option is given. Also following suggestion from issue #6607, added a new switch -diasymreaderPath to CrossGen, to allow loading diasymreader.dll from an alternative path. --- src/zap/zapper.cpp | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'src/zap') diff --git a/src/zap/zapper.cpp b/src/zap/zapper.cpp index 0ad910865b..bcb1b0edca 100644 --- a/src/zap/zapper.cpp +++ b/src/zap/zapper.cpp @@ -240,7 +240,7 @@ STDAPI NGenWorker(LPCWSTR pwzFilename, DWORD dwFlags, LPCWSTR pwzPlatformAssembl return hr; } -STDAPI CreatePDBWorker(LPCWSTR pwzAssemblyPath, LPCWSTR pwzPlatformAssembliesPaths, LPCWSTR pwzTrustedPlatformAssemblies, LPCWSTR pwzPlatformResourceRoots, LPCWSTR pwzAppPaths, LPCWSTR pwzAppNiPaths, LPCWSTR pwzPdbPath, BOOL fGeneratePDBLinesInfo, LPCWSTR pwzManagedPdbSearchPath, LPCWSTR pwzPlatformWinmdPaths) +STDAPI CreatePDBWorker(LPCWSTR pwzAssemblyPath, LPCWSTR pwzPlatformAssembliesPaths, LPCWSTR pwzTrustedPlatformAssemblies, LPCWSTR pwzPlatformResourceRoots, LPCWSTR pwzAppPaths, LPCWSTR pwzAppNiPaths, LPCWSTR pwzPdbPath, BOOL fGeneratePDBLinesInfo, LPCWSTR pwzManagedPdbSearchPath, LPCWSTR pwzPlatformWinmdPaths, LPCWSTR pwzDiasymreaderPath) { HRESULT hr = S_OK; @@ -255,6 +255,10 @@ STDAPI CreatePDBWorker(LPCWSTR pwzAssemblyPath, LPCWSTR pwzPlatformAssembliesPat zap = Zapper::NewZapper(&ngo); +#if defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) + zap->SetDontLoadJit(); +#endif // defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) + if (pwzPlatformAssembliesPaths != nullptr) zap->SetPlatformAssembliesPaths(pwzPlatformAssembliesPaths); @@ -273,6 +277,11 @@ STDAPI CreatePDBWorker(LPCWSTR pwzAssemblyPath, LPCWSTR pwzPlatformAssembliesPat if (pwzPlatformWinmdPaths != nullptr) zap->SetPlatformWinmdPaths(pwzPlatformWinmdPaths); +#if defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) + if (pwzDiasymreaderPath != nullptr) + zap->SetDiasymreaderPath(pwzDiasymreaderPath); +#endif // defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) + // Avoid unnecessary security failures, since permissions are irrelevant when // generating NGEN PDBs zap->SetForceFullTrust(true); @@ -676,6 +685,10 @@ void Zapper::Init(ZapperOptions *pOptions, bool fFreeZapperOptions) _ASSERTE(SUCCEEDED(hr)); #endif +#if defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) + m_fDontLoadJit = false; +#endif // defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) + m_fForceFullTrust = false; } @@ -707,6 +720,11 @@ void Zapper::LoadAndInitializeJITForNgen(LPCWSTR pwzJitName, OUT HINSTANCE* phJi extern HINSTANCE g_hThisInst; #if defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) + if (m_fDontLoadJit) + { + return; + } + if (m_CLRJITPath.GetCount() > 0) { // If we have been asked to load a specific JIT binary, load it. @@ -2215,7 +2233,15 @@ void Zapper::CreatePdbInCurrentDomain(BSTR pAssemblyPathOrName, BSTR pNativeImag tkFile, &hModule)); } - IfFailThrow(::CreatePdb(hAssembly, pNativeImagePath, pPdbPath, pdbLines, pManagedPdbSearchPath)); + LPCWSTR pDiasymreaderPath = nullptr; +#if defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) + if (m_DiasymreaderPath.GetCount() > 0) + { + pDiasymreaderPath = m_DiasymreaderPath.GetUnicode(); + } +#endif // defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) + + IfFailThrow(::CreatePdb(hAssembly, pNativeImagePath, pPdbPath, pdbLines, pManagedPdbSearchPath, pDiasymreaderPath)); } EX_CATCH { @@ -4037,8 +4063,20 @@ void Zapper::SetCLRJITPath(LPCWSTR pwszCLRJITPath) { m_CLRJITPath.Set(pwszCLRJITPath); } + +void Zapper::SetDontLoadJit() +{ + m_fDontLoadJit = true; +} #endif // defined(FEATURE_CORECLR) && !defined(FEATURE_MERGE_JIT_AND_ENGINE) +#if defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) +void Zapper::SetDiasymreaderPath(LPCWSTR pwzDiasymreaderPath) +{ + m_DiasymreaderPath.Set(pwzDiasymreaderPath); +} +#endif // defined(FEATURE_CORECLR) && !defined(NO_NGENPDB) + #if defined(FEATURE_CORECLR) || defined(CROSSGEN_COMPILE) void Zapper::SetPlatformAssembliesPaths(LPCWSTR pwzPlatformAssembliesPaths) -- cgit v1.2.3