Skip to content
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

[LoongArch64] add the coreclr/pal directory #62887

Merged
merged 20 commits into from
Feb 15, 2022
Merged

[LoongArch64] add the coreclr/pal directory #62887

merged 20 commits into from
Feb 15, 2022

Conversation

shushanhf
Copy link
Contributor

[LoongArch64] add the coreclr/pal and libunwind directory.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Dec 16, 2021
@am11
Copy link
Member

am11 commented Dec 16, 2021

@shushanhf, I assume you have just applied libunwind/libunwind@c5f1d12 on v1.6.2 and not copied the upstream master branch, right? If not please only apply the commit which is needed. Also, please update the version file so we can keep track of changes. This helps us when updating libunwind dependency. e.g. in src/coreclr/pal/src/libunwind/libunwind-version.txt, add a line:

Apply https://github.com/libunwind/libunwind/pull/316

@jkotas
Copy link
Member

jkotas commented Dec 16, 2021

It may make sense to submit the libunwind update as separate PR.

@shushanhf
Copy link
Contributor Author

shushanhf commented Dec 17, 2021

@shushanhf, I assume you have just applied libunwind/libunwind@c5f1d12 on v1.6.2 and not copied the upstream master branch, right? If not please only apply the commit which is needed. Also, please update the version file so we can keep track of changes. This helps us when updating libunwind dependency. e.g. in src/coreclr/pal/src/libunwind/libunwind-version.txt, add a line:

Apply https://github.com/libunwind/libunwind/pull/316

In fact we used the first version libunwind for .NET6 and passed, then our company commits it to the upstream.
In this PR, I didn't pull the libunwind from the upstream.

@shushanhf
Copy link
Contributor Author

@shushanhf, I assume you have just applied libunwind/libunwind@c5f1d12 on v1.6.2 and not copied the upstream master branch, right? If not please only apply the commit which is needed. Also, please update the version file so we can keep track of changes. This helps us when updating libunwind dependency. e.g. in src/coreclr/pal/src/libunwind/libunwind-version.txt, add a line:

Apply https://github.com/libunwind/libunwind/pull/316

@shushanhf shushanhf closed this Dec 17, 2021
@shushanhf shushanhf reopened this Dec 17, 2021
@am11
Copy link
Member

am11 commented Dec 17, 2021

I think if you could create a separate PR just for libunwind, as @jkotas suggested (collecting only the libunwind related changes from #62889 and this PR), i.e. everything under src/coreclr/pal/src/libunwind and nothing outside, that would make it quicker to review. Here is an example of such a PR for s390x architecture: #53286.

In terms of bash:

# start fresh
git remote add dotnet https://github.com/dotnet/runtime
git checkout -b feature/loongarch64/libunwind
git fetch --all
git reset --hard dotnet/main

# apply a clean patch
curl -sSL https://github.com/libunwind/libunwind/commit/c5f1d12.patch |\
    git apply - --directory src/coreclr/pal/src/libunwind

# manually update src/coreclr/pal/src/libunwind/libunwind-version.txt
# manually update CMakeLists.txt etc. (as you did in this PR: #62092)
git commit -m "Add loongarch64 support in libunwind"
git push -u origin feature/loongarch64/libunwind
# create a new PR from branch 'feature/loongarch64/libunwind'

The next time someone will update this lib, it will save them trouble to compare files and instead they will just follow our regular steps (#62092 (comment)). I am working on improving it a little bit so we don't modify CMakeLists.txt and friends in vendor's directory and changing libunwind's location to src/native/external; main...am11:feature/consolidations, it is actually ready, I'm just waiting for yours loongarch64 changes to go in first to avoid merge conflicts. :)

@shushanhf
Copy link
Contributor Author

I think if you could create a separate PR just for libunwind, as @jkotas suggested (collecting only the libunwind related changes from #62889 and this PR), i.e. everything under src/coreclr/pal/src/libunwind and nothing outside, that would make it quicker to review. Here is an example of such a PR for s390x architecture: #53286.

In terms of bash:

# start fresh
git remote add dotnet https://github.com/dotnet/runtime
git checkout -b feature/loongarch64/libunwind
git fetch --all
git reset --hard dotnet/main

# apply a clean patch
curl -sSL https://github.com/libunwind/libunwind/commit/c5f1d12.patch |\
    git apply - --directory src/coreclr/pal/src/libunwind

# manually update src/coreclr/pal/src/libunwind/libunwind-version.txt
# manually update CMakeLists.txt etc. (as you did in this PR: #62092)
git commit -m "Add loongarch64 support in libunwind"
git push -u origin feature/loongarch64/libunwind
# create a new PR from branch 'feature/loongarch64/libunwind'

The next time someone will update this lib, it will save them trouble to compare files and instead they will just follow our regular steps (#62092 (comment)). I am working on improving it a little bit so we don't modify CMakeLists.txt and friends in vendor's directory and changing libunwind's location to src/native/external; main...am11:feature/consolidations, it is actually ready, I'm just waiting for yours loongarch64 changes to go in first to avoid merge conflicts. :)

Thanks for your review and advices,
I will update it later.

It will be commited within a new PR.
@shushanhf
Copy link
Contributor Author

I think if you could create a separate PR just for libunwind, as @jkotas suggested (collecting only the libunwind related changes from #62889 and this PR), i.e. everything under src/coreclr/pal/src/libunwind and nothing outside, that would make it quicker to review. Here is an example of such a PR for s390x architecture: #53286.

In terms of bash:

# start fresh
git remote add dotnet https://github.com/dotnet/runtime
git checkout -b feature/loongarch64/libunwind
git fetch --all
git reset --hard dotnet/main

# apply a clean patch
curl -sSL https://github.com/libunwind/libunwind/commit/c5f1d12.patch |\
    git apply - --directory src/coreclr/pal/src/libunwind

# manually update src/coreclr/pal/src/libunwind/libunwind-version.txt
# manually update CMakeLists.txt etc. (as you did in this PR: #62092)
git commit -m "Add loongarch64 support in libunwind"
git push -u origin feature/loongarch64/libunwind
# create a new PR from branch 'feature/loongarch64/libunwind'

The next time someone will update this lib, it will save them trouble to compare files and instead they will just follow our regular steps (#62092 (comment)). I am working on improving it a little bit so we don't modify CMakeLists.txt and friends in vendor's directory and changing libunwind's location to src/native/external; main...am11:feature/consolidations, it is actually ready, I'm just waiting for yours loongarch64 changes to go in first to avoid merge conflicts. :)

Had pushed the libunwind separately by #62979

Comment on lines 65 to 78
if(NOT CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
target_link_libraries(coreclrtraceptprovider
${LTTNG}
)
else()
target_link_libraries(coreclrtraceptprovider
lttng-ust-tracepoint
urcu
urcu-bp
urcu-cds
urcu-common
${LTTNG}
)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, what is the error if we don't make this change? lttng-ust-tracepoint is actually a soft dependency, i.e. this library gets loaded via dlopen() during the run time of application. Even the existing target_link_libraries is not needed, it is a leftover from past refactoring, we can just delete it altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, what is the error if we don't make this change? lttng-ust-tracepoint is actually a soft dependency, i.e. this library gets loaded via dlopen() during the run time of application. Even the existing target_link_libraries is not needed, it is a leftover from past refactoring, we can just delete it altogether.

Yes, I thinks so.
I check it within my machine now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review!
I had deleted the modification. (I guess that it's old code from the mips64 when we porting it.)

@shushanhf
Copy link
Contributor Author

Now this PR can be compiled sucessfully on the native mode.
For example,
https://dev.azure.com/dnceng/public/_build/results?buildId=1522042&view=logs&j=86357178-b8b8-53d0-d37b-335a1e08c946&t=75d29754-3c44-5c16-fcdb-e0edbf440620

What should I do next ?

@shushanhf
Copy link
Contributor Author

@am11
Copy link
Member

am11 commented Dec 21, 2021

The native and managed jitinterfaces used by crossgen2 are not in synchronized state anymore. If int *flags argument is needed by loongarch64, maybe add it to the existing getArgType and leave it unused on the other architectures (#ifndef TARGET_LOONGARCH64\n(void)flags; // unused). Otherwise, add it with a new name like getArgTypeWithFlags. After that run src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh from root of the repo which will take a minute and synchronize the native and managed sides of JIT interface, and adjust the list ordinals in CorInfoBase.cs.

@jkotas
Copy link
Member

jkotas commented Dec 21, 2021

The JIT interface changes should be excluded from this PR. This PR should be only touching the PAL.

@am11
Copy link
Member

am11 commented Dec 21, 2021

Agreed with @jkotas. PAL changes in a separate PR as a first component during a platform port makes things much clearer for coreclr partition.

@shushanhf, could you please revert changes in files which are not under src/coreclr/pal directory? Also:

@shushanhf
Copy link
Contributor Author

The JIT interface changes should be excluded from this PR. This PR should be only touching the PAL.

Agreed with @jkotas. PAL changes in a separate PR as a first component during a platform port makes things much clearer for coreclr partition.

@shushanhf, could you please revert changes in files which are not under src/coreclr/pal directory? Also:

Thanks, I will do it.

@shushanhf shushanhf changed the title [LoongArch64] add the coreclr/pal and libunwind directory [LoongArch64] add the coreclr/pal directory Dec 22, 2021
@BruceForstall BruceForstall added this to the 7.0.0 milestone Feb 14, 2022
@BruceForstall
Copy link
Member

@janvorli Is this something you could review?
cc @mangod9

@shushanhf Looks like some jobs failed. Maybe you need to make sure the branch is up to date and retrigger the testing.

@janvorli
Copy link
Member

@janvorli Is this something you could review?

Yes, I will take a look today.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good, I have just two comments.

CONTEXT_CaptureContext(lpContext);
#else
_ASSERT(!"unimplemented on LOONGARCH64 yet");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be implemented in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.
I had delete the assert for having implements of the CONTEXT_CaptureContext.

@@ -2453,6 +2601,9 @@ PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_
#define PAL_CS_NATIVE_DATA_SIZE 56
#elif defined(__sun) && defined(__x86_64__)
#define PAL_CS_NATIVE_DATA_SIZE 48
#elif defined(__linux__) && defined(__loongarch64)
////TODO for LOONGARCH64: should confirm !!!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to confirm this before merging this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.
I have update it.

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@BruceForstall
Copy link
Member

The CI failures look like unrelated infrastructure. Merging.

@BruceForstall BruceForstall merged commit e7467a8 into dotnet:main Feb 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 17, 2022
@shushanhf shushanhf deleted the main_loongarch64_4 branch May 11, 2022 01:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-loongarch64 area-PAL-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants