Skip to content

[libc] add mremap syscall wrapper #110119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SchrodingerZhu opened this issue Sep 26, 2024 · 14 comments
Closed

[libc] add mremap syscall wrapper #110119

SchrodingerZhu opened this issue Sep 26, 2024 · 14 comments
Assignees
Labels
good first issue https://github.com/llvm/llvm-project/contribute libc

Comments

@SchrodingerZhu
Copy link
Contributor

SchrodingerZhu commented Sep 26, 2024

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:

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"
    ]
}
@SchrodingerZhu SchrodingerZhu added the good first issue https://github.com/llvm/llvm-project/contribute label Sep 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 26, 2024

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
Copy link
Member

llvmbot commented Sep 26, 2024

@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:

@SchrodingerZhu
Copy link
Contributor Author

@SoftJing1 wanted to have a try

@llvmbot
Copy link
Member

llvmbot commented Sep 26, 2024

@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:

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
Copy link
Contributor

I can take a look at this if possible 👍

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Sep 26, 2024

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 (#110122). It should be following largely the same instructions as above.

@WilliamFreedman
Copy link

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

@nickdesaulniers
Copy link
Member

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

@SoftJing1
Copy link
Contributor

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

@lntue
Copy link
Contributor

lntue commented Oct 8, 2024

@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
Copy link

zenmov commented Oct 20, 2024

@SoftJing1 are you still working on this?

@SoftJing1
Copy link
Contributor

@SoftJing1 are you still working on this?

Yes

@whiteio
Copy link
Contributor

whiteio commented Dec 18, 2024

Hi @SoftJing1 are you still working on this? I'd like to do it if not

@SchrodingerZhu
Copy link
Contributor Author

Ah, sorry. It is my fault.

The PR is already merged but I forget to close the issue.

@whiteio thanks for your interest in contributing to LLVM-libc. We do have a lot of other syscall wrappers or libc functions unimplemented but I currently do not have the time to create more good first issues. You are welcome to join the discord to ask whether there are other similar contribution opportunities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue https://github.com/llvm/llvm-project/contribute libc
Projects
None yet
Development

No branches or pull requests

9 participants