[libc] Add minimal Windows config
authorCaitlyn Cano <caitlyncano@google.com>
Thu, 1 Jul 2021 20:41:51 +0000 (20:41 +0000)
committerSiva Chandra Reddy <sivachandra@google.com>
Thu, 1 Jul 2021 20:45:57 +0000 (20:45 +0000)
A README file with procedure for building/testing LLVM libc on Windows
has also been added.

Reviewed By: sivachandra, aeubanks

Differential Revision: https://reviews.llvm.org/D105231

libc/config/windows/README.md [new file with mode: 0644]
libc/config/windows/entrypoints.txt [new file with mode: 0644]

diff --git a/libc/config/windows/README.md b/libc/config/windows/README.md
new file mode 100644 (file)
index 0000000..8e01a40
--- /dev/null
@@ -0,0 +1,76 @@
+# Building and Testing LLVM libc on Windows
+
+## Setting Up Environment
+
+To build LLVM libc on Windows, first build Clang using the following steps.
+
+1. Open Command Prompt in Windows
+2. Set TEMP and TMP to a directory. Creating this path is necessary for a
+   successful clang build.
+    1. Create tmp under your preferred directory or under `C:\src`:
+
+        ```
+        cd C:\src
+        mkdir tmp
+        ```
+
+    2. In the start menu, search for "environment variables for your account".
+       Set TEMP and TMP to `C:\src\tmp` or the corresponding path elsewhere.
+3. Download [Visual Studio Community](https://visualstudio.microsoft.com/downloads/).
+4. Install [CMake](https://cmake.org/download/) and
+   [Ninja](https://github.com/ninja-build/ninja/releases). (Optional, included
+   in Visual Studio).
+5. Load the Visual Studio environment variables using this command. This is
+   crucial as it allows you to use build tools like CMake and Ninja:
+
+    ```
+    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
+    ```
+
+    Note: **Rerun this command every time you open a new Command Prompt
+    window.**
+
+6. If you have not used Git before, install
+   [Git](https://git-scm.com/download/win) for Windows. Check out the LLVM
+   source tree from Github using:
+
+    ```
+    git clone https://github.com/llvm/llvm-project.git
+    ```
+
+7. Ensure you have access to Clang, either by downloading from
+   [LLVM Download](https://releases.llvm.org/download.html) or
+   [building it yourself](https://clang.llvm.org/get_started.html).
+
+## Building LLVM libc
+
+In this section, Clang will be used to compile LLVM
+libc, and finally, build and test the libc.
+
+8. Create a empty build directory in `C:\src` or your preferred directory and
+    cd to it using:
+
+    ```
+    mkdir libc-build
+    cd libc-build
+    ```
+
+9. Run the following CMake command to generate build files. LLVM libc must be built
+   by Clang, so ensure Clang is specified as the C and C++ compiler.
+
+    ```
+    cmake -G Ninja ../llvm-project/llvm -DCMAKE_C_COMPILER=C:/src/clang-build/bin/clang-cl.exe -DCMAKE_CXX_COMPILER=C:/src/clang-build/bin/clang-cl.exe  -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_FORCE_BUILD_RUNTIME=libc -DLLVM_ENABLE_PROJECTS=libc -DLLVM_NATIVE_ARCH=x86_64 -DLLVM_HOST_TRIPLE=x86_64-window-x86-gnu
+    ```
+
+10. Build LLVM libc using:
+
+    ```
+    ninja llvmlibc
+
+    ```
+
+11. Run tests using:
+
+    ```
+    ninja checklibc
+    ```
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
new file mode 100644 (file)
index 0000000..390f2fd
--- /dev/null
@@ -0,0 +1,44 @@
+set(TARGET_LIBC_ENTRYPOINTS
+    # ctype.h entrypoints
+    libc.src.ctype.isalnum
+    libc.src.ctype.isalpha
+    libc.src.ctype.isascii
+    libc.src.ctype.isblank
+    libc.src.ctype.iscntrl
+    libc.src.ctype.isdigit
+    libc.src.ctype.isgraph
+    libc.src.ctype.islower
+    libc.src.ctype.isprint
+    libc.src.ctype.ispunct
+    libc.src.ctype.isspace
+    libc.src.ctype.isupper
+    libc.src.ctype.isxdigit
+    libc.src.ctype.toascii
+    libc.src.ctype.tolower
+    libc.src.ctype.toupper
+    # string.h entrypoints
+    libc.src.string.bzero
+    libc.src.string.memchr
+    libc.src.string.memcmp
+    libc.src.string.memcpy
+    libc.src.string.memmove
+    libc.src.string.memset
+    libc.src.string.memrchr
+    libc.src.string.strcat
+    libc.src.string.strchr
+    libc.src.string.strcpy
+    libc.src.string.strcmp
+    libc.src.string.strcspn
+    libc.src.string.strlen
+    libc.src.string.strncpy
+    libc.src.string.strnlen
+    libc.src.string.strpbrk
+    libc.src.string.strrchr
+    libc.src.string.strspn
+    libc.src.string.strstr
+    libc.src.string.strtok
+    libc.src.string.strtok_r
+)
+set(TARGET_LLVMLIBC_ENTRYPOINTS
+  ${TARGET_LIBC_ENTRYPOINTS}
+)