Skip to content

Commit

Permalink
i#2020: use C++11 in all DR C++ code (#2654)
Browse files Browse the repository at this point in the history
Sets -std=c++11 in the base compiler flags for all DR code.

Refactors configure_DynamoRIO_common(), which used flags set for either C
or C++ depending on the whole target, to be merged and invoked later with
_DR_set_compile_flags(), where we can split the flags by source file rather
than target and have two sets of flags.

Fixes misc warnings with C++11 in various files.

Fixes #2020
  • Loading branch information
derekbruening authored Oct 1, 2017
1 parent 0263e96 commit aa20d1b
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 103 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ set(BASE_CFLAGS "")
set(BASE_CONLY_FLAGS "")
set(BASE_CXXONLY_FLAGS "")
if (UNIX)
set(BASE_CXXONLY_FLAGS "${BASE_CXXONLY_FLAGS} -std=c++11")
# -std=c99 doesn't quite work
# FIXME case 191480: we used to pass -pedantic just to cpp;
# now w/ no separate cpp step we should eliminate the
Expand Down Expand Up @@ -1063,15 +1064,15 @@ endif (UNIX)
# Right now we only support gcc and cl but could change in future
if (DEBUG)
set(CMAKE_C_FLAGS "${BASE_CFLAGS} ${BASE_CONLY_FLAGS} ${DBG} ${DBG_OPT}")
set(CMAKE_CXX_FLAGS "${BASE_CFLAGS} ${BASE_CXXONLY_CFLAGS} ${DBG} ${DBG_OPT}")
set(CMAKE_CXX_FLAGS "${BASE_CFLAGS} ${BASE_CXXONLY_FLAGS} ${DBG} ${DBG_OPT}")
else (DEBUG)
if (CALLPROF)
# no opts -- we need to avoid messing up call frame walking
# FIXME: just disable frame ptr elim opt: but /Oy- ran into some issues
set (OPT "")
endif (CALLPROF)
set(CMAKE_C_FLAGS "${BASE_CFLAGS} ${BASE_CONLY_FLAGS} ${OPT}")
set(CMAKE_CXX_FLAGS "${BASE_CFLAGS} ${BASE_CXXONLY_CFLAGS} ${OPT}")
set(CMAKE_CXX_FLAGS "${BASE_CFLAGS} ${BASE_CXXONLY_FLAGS} ${OPT}")
endif (DEBUG)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINK_EXTRA_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINK_EXTRA_FLAGS}")
Expand Down
4 changes: 2 additions & 2 deletions api/samples/inscount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ event_bb_analysis(void *drcontext, void *tag, instrlist_t *bb,
uint num_instrs;

#ifdef VERBOSE
dr_printf("in dynamorio_basic_block(tag="PFX")\n", tag);
dr_printf("in dynamorio_basic_block(tag=" PFX")\n", tag);
# ifdef VERBOSE_VERBOSE
instrlist_disassemble(drcontext, tag, bb, STDOUT);
# endif
Expand All @@ -171,7 +171,7 @@ event_bb_analysis(void *drcontext, void *tag, instrlist_t *bb,
*user_data = (void *)(ptr_uint_t)num_instrs;

#if defined(VERBOSE) && defined(VERBOSE_VERBOSE)
dr_printf("Finished counting for dynamorio_basic_block(tag="PFX")\n", tag);
dr_printf("Finished counting for dynamorio_basic_block(tag=" PFX")\n", tag);
instrlist_disassemble(drcontext, tag, bb, STDOUT);
#endif
return DR_EMIT_DEFAULT;
Expand Down
4 changes: 0 additions & 4 deletions clients/drcachesim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ else ()
add_definitions(-DUNIX)
endif ()

if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif ()

# i#2277: we use zlib if available to read compressed trace files.
# XXX: we could ship with a zlib for Windows: today we simply don't support
# compressed traces on Windows.
Expand Down
Loading

0 comments on commit aa20d1b

Please sign in to comment.