diff --git a/openmp/libomptarget/include/Debug.h b/openmp/libomptarget/include/Debug.h
--- a/openmp/libomptarget/include/Debug.h
+++ b/openmp/libomptarget/include/Debug.h
@@ -53,7 +53,8 @@
   OMP_INFOTYPE_ALL = 0xffffffff,
 };
 
-static inline uint32_t getInfoLevel() {
+// Add __attribute__((used)) to work around a bug in gcc 5/6.
+static inline uint32_t __attribute__((used)) getInfoLevel() {
   static uint32_t InfoLevel = 0;
   static std::once_flag Flag{};
   std::call_once(Flag, []() {
@@ -64,7 +65,8 @@
   return InfoLevel;
 }
 
-static inline uint32_t getDebugLevel() {
+// Add __attribute__((used)) to work around a bug in gcc 5/6.
+static inline uint32_t __attribute__((used)) getDebugLevel() {
   static uint32_t DebugLevel = 0;
   static std::once_flag Flag{};
   std::call_once(Flag, []() {