llvm / llvm-project

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

[libc] add `mremap` syscall wrapper #110119

Open SchrodingerZhu opened 1 month ago

SchrodingerZhu commented 1 month ago

We need to create a mremap wrapper for linux targets, see https://man7.org/linux/man-pages/man2/mremap.2.html.

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 1 month 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 1 month ago

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

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

We need to create a `mremap` wrapper for linux targets, see https://man7.org/linux/man-pages/man2/mremap.2.html. This requires: - 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 in the header spec - modify `functions` section in `libc/newhdrgen/yaml/sys/mman.yaml` - modify `SysMMan` section in `libc/spec/linux.td` - add in 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
SchrodingerZhu commented 1 month ago

@SoftJing1 wanted to have a try

llvmbot commented 1 month ago

@llvm/issue-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

We need to create a `mremap` wrapper for linux targets, see https://man7.org/linux/man-pages/man2/mremap.2.html. This requires: - 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 in the header spec - modify `functions` section in `libc/newhdrgen/yaml/sys/mman.yaml` - modify `SysMMan` section in `libc/spec/linux.td` - add in 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 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" ] } ```
AlyElashram commented 1 month ago

I can take a look at this if possible 👍

SchrodingerZhu commented 1 month ago

hi @AlyElashram, @SoftJing1 is currently looking into this. I will let you know if anything changed. That is being said, I have opened another issue for remap_file_pages if you want to have a try (https://github.com/llvm/llvm-project/issues/110122). It should be following largely the same instructions as above.

WilliamFreedman commented 1 month ago

Looks like nobody's currently assigned, I'd love to take a look at it if that's right.

nickdesaulniers commented 1 month ago

@WilliamFreedman we can't assign users who aren't members of the llvm github org. It sounds like @softjing1 is looking into this?

SoftJing1 commented 1 month ago

@WilliamFreedman @nickdesaulniers Yes I am currently working on this, and hopefully will get it done this week.

lntue commented 1 month ago

@WilliamFreedman we can't assign users who aren't members of the llvm github org. It sounds like @SoftJing1 is looking into this?

On the side note, I think we can assign it if the users comment on the issue. Members of llvm github org will have commit rights to the repo.

zenmov commented 3 weeks ago

@SoftJing1 are you still working on this?

SoftJing1 commented 3 weeks ago

@SoftJing1 are you still working on this?

Yes