diff --git a/core/rootcling_stage1/src/rootcling_stage1.cxx b/core/rootcling_stage1/src/rootcling_stage1.cxx
index 44f83c0d315563fedbb18b50842ced5584c33e12..ffb5a7ef3ae4d13651df37ec22a94bbbc156d0b7 100644
--- a/core/rootcling_stage1/src/rootcling_stage1.cxx
+++ b/core/rootcling_stage1/src/rootcling_stage1.cxx
@@ -17,6 +17,8 @@ extern "C" {
    R__DLLEXPORT void usedToIdentifyRootClingByDlSym() {}
 }
 
+// force compiler to emit symbol for function above
+static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;
 
 ROOT::Internal::RootCling::TROOTSYSSetter gROOTSYSSetter;
 
@@ -32,12 +34,7 @@ static const char *GetEtcDir() {
 
 int main(int argc, char **argv)
 {
-   // Force the emission of the symbol - the compiler cannot know that argv
-   // is always set.
-   if (!argv) {
-      auto dummyVal =  (int)(long)&usedToIdentifyRootClingByDlSym;
-      return dummyVal;
-   }
+   (void) dlsymaddr; // avoid unused variable warning
 
    ROOT::Internal::RootCling::DriverConfig config{};
 
diff --git a/main/src/rootcling.cxx b/main/src/rootcling.cxx
index d06fdb32dc81453950a5b2f532d5ef03d27dae4d..8165ce2e1293aa3dce0473fa3f261e6cb80aa1e5 100644
--- a/main/src/rootcling.cxx
+++ b/main/src/rootcling.cxx
@@ -19,14 +19,12 @@ extern "C" {
    R__DLLEXPORT void usedToIdentifyRootClingByDlSym() {}
 }
 
+// force compiler to emit symbol for function above
+static void (*dlsymaddr)() = &usedToIdentifyRootClingByDlSym;
+
 int main(int argc, char **argv)
 {
-   // Force the emission of the symbol - the compiler cannot know that argv
-   // is always set.
-   if (!argv) {
-      auto dummyVal =  (int)(long)&usedToIdentifyRootClingByDlSym;
-      return dummyVal;
-   }
+   (void) dlsymaddr; // avoid unused variable warning
 
    ROOT::Internal::RootCling::DriverConfig config{};