[PATCH] D68045: [builtins] Unbreak build on FreeBSD armv7 after D60351

Jan Beich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 25 12:22:37 PDT 2019


jbeich created this revision.
jbeich added reviewers: phosek, echristo.
Herald added subscribers: llvm-commits, Sanitizers, jfb, JDevlieghere, kristof.beyls, emaste.
Herald added projects: Sanitizers, LLVM.

According to FreeBSD style(9) <https://man.freebsd.org/style/9> and OpenBSD style(9) <https://man.openbsd.org/style.9> either `<sys/types.h>` or `<sys/param.h>` must come before any other header. Many system headers are not self-sufficient to avoid namespace pollution.

Found downstream via Rust <https://reviews.freebsd.org/D21778#475574>

  c
  # FreeBSD
  $ echo '#include <machine/sysarch.h>' | cc -xc -
  In file included from <stdin>:1:
  In file included from /usr/include/machine/sysarch.h:42:
  /usr/include/machine/armreg.h:47:2: error: Please include sys/cdefs.h before including machine/armreg.h
  #error Please include sys/cdefs.h before including machine/armreg.h
   ^
  1 error generated.
  
  # OpenBSD
  $ echo '#include <machine/sysarch.h>' | cc -xc -
  In file included from <stdin>:1:
  /usr/include/machine/sysarch.h:47: error: expected specifier-qualifier-list before 'u_int32_t'
  In file included from <stdin>:1:
  /usr/include/machine/sysarch.h:56: error: expected ')' before 'addr'

Test Plan:
Trying to figure out how to build compiler-rt without Clang.
devel/llvm90 on FreeBSD doesn't build compiler-rt builtins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68045

Files:
  compiler-rt/lib/builtins/atomic.c
  compiler-rt/lib/builtins/clear_cache.c


Index: compiler-rt/lib/builtins/clear_cache.c
===================================================================
--- compiler-rt/lib/builtins/clear_cache.c
+++ compiler-rt/lib/builtins/clear_cache.c
@@ -23,8 +23,10 @@
 #endif
 
 #if defined(__FreeBSD__) && defined(__arm__)
-#include <machine/sysarch.h>
+// clang-format off
 #include <sys/types.h>
+#include <machine/sysarch.h>
+// clang-format on
 #endif
 
 #if defined(__NetBSD__) && defined(__arm__)
@@ -32,8 +34,10 @@
 #endif
 
 #if defined(__OpenBSD__) && defined(__mips__)
-#include <machine/sysarch.h>
+// clang-format off
 #include <sys/types.h>
+#include <machine/sysarch.h>
+// clang-format on
 #endif
 
 #if defined(__linux__) && defined(__mips__)
Index: compiler-rt/lib/builtins/atomic.c
===================================================================
--- compiler-rt/lib/builtins/atomic.c
+++ compiler-rt/lib/builtins/atomic.c
@@ -51,9 +51,11 @@
 ////////////////////////////////////////////////////////////////////////////////
 #ifdef __FreeBSD__
 #include <errno.h>
-#include <machine/atomic.h>
+// clang-format off
 #include <sys/types.h>
+#include <machine/atomic.h>
 #include <sys/umtx.h>
+// clang-format on
 typedef struct _usem Lock;
 __inline static void unlock(Lock *l) {
   __c11_atomic_store((_Atomic(uint32_t) *)&l->_count, 1, __ATOMIC_RELEASE);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68045.221818.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190925/f4341506/attachment.bin>


More information about the llvm-commits mailing list