llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.6k stars 11.82k forks source link

[libc] add linux mman extension `process_mrelease` #110124

Open SchrodingerZhu opened 3 weeks ago

SchrodingerZhu commented 3 weeks ago

We need to create a process_mrelease wrapper for linux targets, see https://lwn.net/Articles/865341/. This is already inside glibc.

This requires:


Misc:

If you use vscode, sample settings are as the following (optional settings are useful in speeding up the compilation):

{
    "cmake.sourceDirectory": "${workspaceFolder}/runtimes",
    "cmake.configureSettings": {
        "CMAKE_EXPORT_COMPILE_COMMANDS": true,
        "LLVM_ENABLE_RUNTIMES": [
            "libc",
            "compiler-rt"
        ],
        "LLVM_LIBC_FULL_BUILD": true,
        "LLVM_USE_LINKER": "lld", // optional: requires installing lld
        "CMAKE_CXX_COMPILER_LAUNCHER": "sccache", // optional: requires installing sccache first
        "CMAKE_C_COMPILER_LAUNCHER": "sccache", // optional: requires installing sccache first
        "CMAKE_CXX_COMPILER": "/usr/bin/clang++",
        "CMAKE_C_COMPILER": "/usr/bin/clang",
        "LLVM_LIBC_INCLUDE_SCUDO": true,
        "COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC": true,
        "COMPILER_RT_BUILD_GWP_ASAN": false,
        "COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED": false,
        "LIBC_USE_NEW_HEADER_GEN": true
    },
    "cmake.generator": "Ninja", // optional: requires installing Ninja
    "editor.formatOnSave": true,
    "files.insertFinalNewline": true,
    "clangd.arguments": [
        "--header-insertion=never"
    ]
}
llvmbot commented 3 weeks ago

Hi!

This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:

  1. Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
  2. In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
  3. Fix the issue locally.
  4. Run the test suite locally. Remember that the subdirectories under test/ create fine-grained testing targets, so you can e.g. use make check-clang-ast to only run Clang's AST tests.
  5. Create a Git commit.
  6. Run git clang-format HEAD~1 to format your changes.
  7. Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.

If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.

llvmbot commented 3 weeks ago

@llvm/issue-subscribers-good-first-issue

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

We need to create a `process_mrelease` wrapper for linux targets, see https://lwn.net/Articles/865341/. This is already inside glibc. This requires: - add syscall number into `libc/include/sys/syscall.h.def` - implement the entrypoint header similar to `libc/src/sys/mman/mmap.h` - modify `libc/src/sys/mman/CMakeLists.txt` accordingly - implement the entrypoint similar to `libc/src/sys/mman/linux/mmap.cpp` - modify `libc/src/sys/mman/linux/CMakeLists.txt` accordingly - add the header spec - modify `functions` section in `libc/newhdrgen/yaml/sys/mman.yaml` - modify `SysMMan` section in `libc/spec/linux.td` - add test - similar to `libc/test/src/sys/mman/linux/mmap_test.cpp` - modify `libc/test/src/sys/mman/linux/CMakeLists.txt` accordingly ----------------------------------------------------- Misc: - How to build libc for dev: https://libc.llvm.org/full_host_build.html - Code style and dev guide: https://libc.llvm.org/dev/index.html If you use vscode, [sample settings](https://code.visualstudio.com/docs/getstarted/settings#_settings-json-file) are as the following (optional settings are useful in speeding up the compilation): ``` { "cmake.sourceDirectory": "${workspaceFolder}/runtimes", "cmake.configureSettings": { "CMAKE_EXPORT_COMPILE_COMMANDS": true, "LLVM_ENABLE_RUNTIMES": [ "libc", "compiler-rt" ], "LLVM_LIBC_FULL_BUILD": true, "LLVM_USE_LINKER": "lld", // optional: requires installing lld "CMAKE_CXX_COMPILER_LAUNCHER": "sccache", // optional: requires installing sccache first "CMAKE_C_COMPILER_LAUNCHER": "sccache", // optional: requires installing sccache first "CMAKE_CXX_COMPILER": "/usr/bin/clang++", "CMAKE_C_COMPILER": "/usr/bin/clang", "LLVM_LIBC_INCLUDE_SCUDO": true, "COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC": true, "COMPILER_RT_BUILD_GWP_ASAN": false, "COMPILER_RT_SCUDO_STANDALONE_BUILD_SHARED": false, "LIBC_USE_NEW_HEADER_GEN": true }, "cmake.generator": "Ninja", // optional: requires installing Ninja "editor.formatOnSave": true, "files.insertFinalNewline": true, "clangd.arguments": [ "--header-insertion=never" ] } ```
moar55 commented 3 weeks ago

I would like to take this if possible :)

SchrodingerZhu commented 3 weeks ago

Sure. go ahead.