Skip to content

Commit 89696ca

Browse files
bellenotvgvassilev
andauthored
[win] Fix build and tests with winrtdebug=ON (#19404)
* [win] Fix build and tests with winrtdebug=ON - Add the -RTC1 (runtime check) compiler flag with winrtdebug=ON and dev=ON - Add the -D_ITERATOR_DEBUG_LEVEL=0 flag where needed, to work-around the issue with STL iterators and I/O. This produce incompatible debug binaries, but allows to debug ROOT - Add the LLVM_ENABLE_DUMP=TRUE option when LLVM_BUILD_TYPE is Debug or RelWithDebInfo - Fix gtest-tree-ntuple-ntuple-packing, which was failing for one bit difference * Update interpreter/CMakeLists.txt Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com> * Update interpreter/CMakeLists.txt * Update interpreter/CMakeLists.txt * Revert changes in tree/ntuple/src/RColumnElement.hxx * debug and optimized are exclusive on Windows only --------- Co-authored-by: Vassil Vassilev <v.g.vassilev@gmail.com>
1 parent 6dcab08 commit 89696ca

File tree

8 files changed

+37
-5
lines changed

8 files changed

+37
-5
lines changed

cmake/modules/SetUpWindows.cmake

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ elseif(MSVC)
3131
math(EXPR VC_MINOR "${MSVC_VERSION} % 100")
3232

3333
#---Select compiler flags----------------------------------------------------------------
34+
if(winrtdebug AND dev)
35+
set(ROOT_RTC_FLAGS "-RTC1")
36+
endif()
3437
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-MD -O2 -Ob2 -Z7 -DNDEBUG")
3538
set(CMAKE_CXX_FLAGS_MINSIZEREL "-MD -O1 -Ob1 -DNDEBUG")
3639
set(CMAKE_CXX_FLAGS_RELEASE "-MD -O2 -Ob2 -DNDEBUG")
37-
set(CMAKE_CXX_FLAGS_DEBUG "-MDd -Od -Ob0 -Z7")
40+
set(CMAKE_CXX_FLAGS_DEBUG "-MDd -Od -Ob0 -Z7 ${ROOT_RTC_FLAGS}")
3841
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-MD -O2 -Ob2 -Z7 -DNDEBUG")
3942
set(CMAKE_C_FLAGS_MINSIZEREL "-MD -O1 -Ob1 -DNDEBUG")
4043
set(CMAKE_C_FLAGS_RELEASE "-MD -O2 -Ob2 -DNDEBUG")
41-
set(CMAKE_C_FLAGS_DEBUG "-MDd -Od -Ob0 -Z7")
44+
set(CMAKE_C_FLAGS_DEBUG "-MDd -Od -Ob0 -Z7 ${ROOT_RTC_FLAGS}")
4245

4346
if(winrtdebug)
4447
if (CMAKE_SIZEOF_VOID_P EQUAL 8)

cmake/scripts/compiledata.win32.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#define COMPILERVERSSTR "@CMAKE_CXX_COMPILER_ID@ @CMAKE_CXX_COMPILER_VERSION@"
88
#define MAKESHAREDLIB "cl $Opt -nologo -TP -c @CMAKE_CXX_FLAGS@ @BLDCXXFLAGS@ $IncludePath $SourceFiles -Fo$ObjectFiles && bindexplib $LibName $ObjectFiles > $BuildDir\\$LibName.def && lib -nologo -MACHINE:@MACHINE_ARCH@ -out:$BuildDir\\$LibName.lib $ObjectFiles -def:$BuildDir\\$LibName.def && link -nologo $ObjectFiles -DLL -out:$BuildDir\\$LibName.dll $BuildDir\\$LibName.exp -LIBPATH:%ROOTSYS%\\lib $LinkedLibs libCore.lib kernel32.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib && if EXIST \"$BuildDir\\$LibName.dll.manifest\" ( mt -nologo -manifest \"$BuildDir\\$LibName.dll.manifest\" \"-outputresource:$BuildDir\\$LibName.dll;2\" && del \"$BuildDir\\$LibName.dll.manifest\" )"
99
#define MAKEEXE "cl -nologo -TP -Iinclude -I..\\include -c $Opt @CMAKE_CXX_FLAGS@ @BLDCXXFLAGS@ $IncludePath $SourceFiles && link -opt:ref @CMAKE_EXE_FLAGS@ $ObjectFiles $LinkedLibs advapi32.lib -out:$ExeName && if EXIST \"$ExeName.exe.manifest\" ( mt -nologo -manifest \"$ExeName.exe.manifest\" \"-outputresource:$ExeName.exe;1\" && del \"$ExeName.exe.manifest\" )"
10-
#define CXXOPT "@CMAKE_CXX_FLAGS_RELEASE@"
11-
#define CXXDEBUG "@CMAKE_CXX_FLAGS_DEBUG@"
10+
#define CXXOPT "@CMAKE_CXX_FLAGS_RELEASE@ @BLDCXXFLAGS@"
11+
#define CXXDEBUG "@CMAKE_CXX_FLAGS_DEBUG@ @BLDCXXFLAGS@"
1212
#define ROOTBUILD "release"
1313
#define LINKEDLIBS "-LIBPATH:%ROOTSYS%\\lib libCore.lib "
1414
#define INCLUDEPATH "-I%ROOTSYS%\\include"

core/base/src/TSystem.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,12 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
28852885
mode = kDebug;
28862886
}
28872887
}
2888+
#if defined(_MSC_VER) && defined(_DEBUG)
2889+
// if ROOT is build in debug mode, ACLiC must also build in debug mode
2890+
// for compatibility reasons
2891+
if (!(mode & kDebug))
2892+
mode |= kDebug;
2893+
#endif
28882894
UInt_t verboseLevel = verbose ? 7 : gDebug;
28892895
Bool_t flatBuildDir = (fAclicProperties & kFlatBuildDir) || (opt && strchr(opt,'-')!=nullptr);
28902896

@@ -3729,12 +3735,18 @@ int TSystem::CompileMacro(const char *filename, Option_t *opt,
37293735
TString optdebFlags;
37303736
if (mode & kDebug)
37313737
optdebFlags = fFlagsDebug + " ";
3738+
#ifdef WIN32
3739+
else
3740+
#endif
37323741
if (mode & kOpt)
37333742
optdebFlags += fFlagsOpt;
37343743
cmd.ReplaceAll("$Opt", optdebFlags);
37353744
#ifdef WIN32
37363745
R__FixLink(cmd);
37373746
cmd.ReplaceAll("-std=", "-std:");
3747+
if (mode & kDebug) {
3748+
cmd.ReplaceAll(" && link ", "&& link /DEBUG ");
3749+
}
37383750
#endif
37393751

37403752
TString testcmd = fMakeExe;

core/dictgen/src/rootcling_impl.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,10 @@ void AddPlatformDefines(std::vector<std::string> &clingArgs)
21352135
clingArgs.push_back(platformDefines);
21362136
snprintf(platformDefines, 64, "-DG__VISUAL=%ld", (long)_MSC_VER);
21372137
clingArgs.push_back(platformDefines);
2138+
#if defined(_WIN64) && defined(_DEBUG)
2139+
snprintf(platformDefines, 64, "-D_ITERATOR_DEBUG_LEVEL=0");
2140+
clingArgs.push_back(platformDefines);
2141+
#endif
21382142
#endif
21392143
}
21402144

graf2d/win32gdk/gdk/src/glib/gmessages.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ g_logv (const gchar *log_domain,
544544
#endif
545545
# if defined (_MSC_VER) && defined (_DEBUG)
546546
/* let's see the call stack ... */
547-
__asm int 3
547+
/* __asm int 3 */
548+
__debugbreak();
548549
# endif
549550
abort ();
550551
#endif /* !G_ENABLE_DEBUG || !SIGTRAP */

interpreter/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,12 @@ if(builtin_llvm)
176176
if(CMAKE_BUILD_TYPE MATCHES "Debug"
177177
OR LLVM_BUILD_TYPE MATCHES "(Debug|RelWithDebInfo)")
178178
set(LLVM_ENABLE_ASSERTIONS TRUE)
179+
if(NOT DEFINED LLVM_ENABLE_DUMP)
180+
set(LLVM_ENABLE_DUMP TRUE)
181+
endif()
179182
else()
180183
set(LLVM_ENABLE_ASSERTIONS FALSE)
184+
set(LLVM_ENABLE_DUMP FALSE)
181185
endif()
182186
endif()
183187

interpreter/cling/lib/Interpreter/CIFactory.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ namespace {
849849
PPOpts.addMacroDef("__CLING__GNUC_MINOR__=" ClingStringify(__GNUC_MINOR__));
850850
#elif defined(_MSC_VER)
851851
PPOpts.addMacroDef("__CLING__MSVC__=" ClingStringify(_MSC_VER));
852+
#if defined(_WIN64) && defined(_DEBUG)
853+
PPOpts.addMacroDef("_ITERATOR_DEBUG_LEVEL=0");
854+
#endif
852855
#endif
853856

854857
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

io/io/src/TFile.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,6 +3222,11 @@ void TFile::MakeProject(const char *dirname, const char * /*classes*/,
32223222
} else {
32233223
sOpt = gSystem->GetFlagsDebug();
32243224
}
3225+
#if defined(_MSC_VER) && defined(_DEBUG)
3226+
// if ROOT is build in debug mode, ACLiC must also build in debug mode
3227+
// for compatibility reasons
3228+
sOpt = gSystem->GetFlagsDebug();
3229+
#endif
32253230
cmd.ReplaceAll("$Opt", sOpt);
32263231

32273232
if (genreflex) {

0 commit comments

Comments
 (0)