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

uClibc and -checkaction=C #3078

Closed
sarneaud opened this issue May 28, 2019 · 4 comments · Fixed by #3082
Closed

uClibc and -checkaction=C #3078

sarneaud opened this issue May 28, 2019 · 4 comments · Fixed by #3082

Comments

@sarneaud
Copy link

uClibc's assert() implementation uses a 4-parameter __assert() function, like the __assert_fail() function in other libcs.

Currently ldc2 doesn't recognise uClibc and falls back to generating code for a 3-parameter __assert(). I don't see an easy fix because LLVM's target triples don't seem to support uClibc.

@kinke
Copy link
Member

kinke commented May 28, 2019

I don't see an easy fix because LLVM's target triples don't seem to support uClibc.

We have this as workaround for that:

ldc/driver/main.cpp

Lines 536 to 545 in 7474c19

void fixupUClibcEnv() {
llvm::Triple triple(mTargetTriple);
if (triple.getEnvironmentName().find("uclibc") != 0)
return;
std::string envName = triple.getEnvironmentName();
envName.replace(0, 6, "gnu");
triple.setEnvironmentName(envName);
mTargetTriple = triple.normalize();
isUClibc = true;
}

This isUClibc is currently only used to set the predefined version CRuntime_UClibc. We'd need to adapt this too:

ldc/gen/runtime.cpp

Lines 378 to 390 in 5e5ce19

static std::vector<PotentiallyLazyType> getCAssertFunctionParamTypes() {
const auto voidPtr = Type::tvoidptr;
const auto uint = Type::tuns32;
if (global.params.targetTriple->isOSDarwin() ||
global.params.targetTriple->isOSSolaris() || isMusl()) {
return {voidPtr, voidPtr, uint, voidPtr};
}
if (global.params.targetTriple->getEnvironment() == llvm::Triple::Android) {
return {voidPtr, uint, voidPtr};
}
return {voidPtr, voidPtr, uint};
}

@rracariu
Copy link
Contributor

uClibc will work at least ARM and MIPS were tested to some extent, see the status issues: #2995 and #2810 - MIPS still has issues with ABI compatibility but this is not related to uClibc.

To enable uClibc support the triple looks like armv6-hardfloat-linux-uclibceabi or mipsel-unknown-linux-uclibc

@sarneaud
Copy link
Author

@rracariu Thanks, but this is specifically a problem with -checkaction=C and uClibc, not uClibc support in general.

@rracariu
Copy link
Contributor

@sarneaud OK, got it. Then exposing isUClibc outside main.cpp should work.
Maybe have a helper function similar to isMusl()

kinke added a commit to kinke/ldc that referenced this issue May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants