[PATCH] D36720: [libc++] Prevent stale site configuration headers

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 16:17:56 PDT 2017


smeenai created this revision.
Herald added a subscriber: mgorny.

If we define cmake macros that require a site config, and then undefine
all such macros, a stale site config header will be left behind.
Explicitly delete any generate site config if we don't need one to avoid
this.


https://reviews.llvm.org/D36720

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -615,9 +615,10 @@
   config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
 endif()
 
+set(site_config_path "${LIBCXX_BINARY_DIR}/__config_site")
 if (LIBCXX_NEEDS_SITE_CONFIG)
   configure_file("include/__config_site.in"
-                 "${LIBCXX_BINARY_DIR}/__config_site"
+                 "${site_config_path}"
                  @ONLY)
 
   # Provide the config definitions by included the generated __config_site
@@ -627,6 +628,10 @@
   else()
     add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site")
   endif()
+else()
+  if (EXISTS "${site_config_path}")
+    file(REMOVE "${site_config_path}")
+  endif()
 endif()
 
 #===============================================================================


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36720.111096.patch
Type: text/x-patch
Size: 855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170814/74335a1b/attachment.bin>


More information about the cfe-commits mailing list