[libc-commits] [PATCH] D82404: [libc] Minimal Darwin support

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Fri Jul 10 11:50:38 PDT 2020


sivachandra added inline comments.


================
Comment at: libc/config/darwin/platfrom_defs.h.inc:11
+
+#define LLVM_LIBC_ALIAS(_ret_type, _name, _arglist, ...) \
+  extern "C" {                                           \
----------------
This is probably OK as a compromise. Few points around this:

1. If we are actually OK with this in general and not just for Darwin, then we don' t need to use aliases at all. We can use an arrangement like this:

``` 
// entrypoint.h

#define ENTRYPOINT_DECL extern "C"

namespace __llvm_libc {

ENTRYPOINT_DECL <ret_type> entrypoint(<argl list>);

} // namespace __llvm_libc
```

```
// entrypoint.cpp
#include "entrypoint.h"

namespace __llvm_libc {

<ret_type> entrypoint(<arg list>) {
 ...
}

} // namespace __llvm_libc
```

This gives you a C symbol but requires scope qualification in the callers from within LLVM libc. Exactly what we want.

2. But, LLVM libc aims to be intermixed with other libcs In which case, the above mechanism or even using aliases, does not give us a way to ensure that calls from within LLVM libc to other LLVM libc entrypoints resolve to symbols from LLVM libc itself. This was the reason why we went with the `LLVM_LIBC_ENTRYPOINT` macro as it is today for linux.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82404/new/

https://reviews.llvm.org/D82404





More information about the libc-commits mailing list