Skip to content

build llvm libc #39

Closed
Closed

Description

@nickdesaulniers

Follow up to #36 (comment).
Specifically, it would be nice to test out memcpy, memset, memcmp, and strlen from llvm-libc.

There's a few issues though. We'd maybe want to build it as part of epoch2, but:

  1. llvmlibc has some build failures in 14.0.1. I need to cherry-pick a hacked up version of commit 122da690b39a ("[libc] Fix build when __FE_DENORM is defined").
  2. llvmlibc build seems to depend on musl-dev to build in the env (wtf)
  3. llvmlibc build seems to depend on kernel headers, which we don't build for epoch2 but do for epoch3. I think we might need to thus build llvmlibc BEFORE building clang in epoch3...

Alternatively, clang can assemble some glibc implementations of the above. 😈

cc @compnerd

Activity

  1. nickdesaulniers commented on Jul 11, 2022

    @nickdesaulniers
    MemberAuthor

    Here's a profile of llvmlibc used in stage3 to build a kernel:

    Samples: 12M of event 'cycles:ppu', Event count (approx.): 9050605813458
      Overhead  Shared Object             Symbol
    +    3.04%  clang                     [.] clang::SourceManager::getFileIDLocal
    +    2.12%  clang                     [.] llvm::StringMapImpl::LookupBucketFor
    +    1.68%  clang                     [.] clang::TokenLexer::Lex
    +    1.64%  clang                     [.] clang::Lexer::LexTokenInternal
    +    1.06%  clang                     [.] clang::Preprocessor::Lex
    +    1.04%  clang                     [.] clang::ASTContext::getDeclAttrs
    +    1.03%  clang                     [.] clang::Lexer::LexIdentifierContinue
    +    0.99%  clang                     [.] GetFullTypeForDeclarator
    +    0.97%  clang                     [.] (anonymous namespace)::IntExprEvaluator::VisitBinaryOper
    +    0.94%  clang                     [.] CheckICE
    +    0.81%  clang                     [.] clang::TokenLexer::ExpandFunctionArguments
    +    0.81%  clang                     [.] clang::SourceManager::getFileID
    +    0.66%  clang                     [.] memcpy
         0.58%  clang                     [.] free
    +    0.54%  clang                     [.] clang::Parser::ParseDeclarationSpecifiers
         0.52%  clang                     [.] strlen
    +    0.51%  clang                     [.] clang::Preprocessor::getMacroDefinition
         0.50%  clang                     [.] GetDiagInfo
         0.49%  clang                     [.] llvm::FoldingSetBase::FindNodeOrInsertPos
         0.47%  clang                     [.] memset
         0.47%  clang                     [.] AnalyzeImplicitConversions
         0.46%  clang                     [.] clang::Sema::LookupName
         0.43%  clang                     [.] malloc
         0.43%  clang                     [.] clang::Parser::ParseCastExpression
         0.43%  clang                     [.] clang::DiagnosticIDs::getDiagnosticSeverity
         0.42%  clang                     [.] clang::Preprocessor::ReadMacroCallArgumentList
         0.41%  clang                     [.] clang::Expr::IgnoreParenImpCasts
         0.40%  clang                     [.] clang::RecursiveASTVisitor<(anonymous namespace)::Fallth
         0.40%  clang                     [.] clang::Sema::ActOnFunctionDeclarator
         0.39%  clang                     [.] memcmp
    

    compare vs musl. Or:

    musl:

    +    1.40%  clang                      [.] memcpy
    +    0.65%  clang                      [.] memset
         0.50%  clang                      [.] memcmp
         0.46%  clang                      [.] strlen
    

    llvm-libc:

    +    0.66%  clang                     [.] memcpy
         0.52%  clang                     [.] strlen
         0.47%  clang                     [.] memset
         0.39%  clang                     [.] memcmp
    

    (memcmp falls out of the top 20)
    so llvm-libc is a win here (maybe not for strlen though :( )

  2. added a commit that references this issue on Jul 14, 2022
    8373a2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions