[libc-dev] Location qualified target names

Siva Chandra via libc-dev libc-dev at lists.llvm.org
Fri Jan 17 13:16:43 PST 2020


As we start adding more targets, it is getting harder to remember
which exact target one should be building to test/build something.
Moreover, some target names are not explicitly listed in a
CMakeLists.txt file. The name listed in the file is prefixed and/or
suffixed by the corresponding rule to generate a real full target
name. Further, D72516 adds a target by name `json`. Considering that
the target names are llvm-project global, I do not think it is a good
idea to have generic names like `json`. [For the record however, I do
not think that the patch got the naming wrong. Infact, for what the
patch seems to be adding, the name `json` seems natural/appropriate.]

I propose that target names in llvm-libc be location qualified. For
example, the implementation of `memcpy` lives in `src/string` and
currently has a target name of `memcpy`. A location qualified name for
this target would be `libc.src.string.memcpy`. Likewise, the `json`
target above would get the name `libc.utils.benchmark.json`. One
should not need to list the fully qualified names in the
CMakeLists.txt files. Libc's CMake rules will do the "magic" of
creating the right fully qualified target name.

Few additional conveniences that can be built over this scheme:
1. Each directory will have an implicit `all` target. For example,
`libc.src.string.all` will build all implementations in src/string.
This implicit target will not run tests even if present.
2. Likewise, each directory will also have an implicit `run_tests`
target which will run all tests in the directory iff present.

Targets which are listed using LLVM build rules will be special and
their naming has to be something appropriate to the context. For
example, libc-hdrgen. Targets like `check-libc` will also be special
and still be available in order to retain the consistency with the
rest of llvm-project.

Using location qualified names as described above can lead to very
long names. But, in my opinion, the organized naming scheme is a very
big plus which outweighs the burden of long target names.

Thanks,
Siva Chandra


More information about the libc-dev mailing list