Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-99598

Fix clang using the wrong gcc installation on v5 toolchain

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • ALL
    • Programmability 2025-01-20, Programmability 2025-02-03

      On non AL2023 build variants (tested on AL2 and Ubuntu22.04), the built clang uses the GCC installation in /usr (system default on new images). This makes the built clang more system dependent. For example, the loader that clang uses is /usr/bin/ld, and the object files that clang links are from /usr.

      This is inconsistent with v4's clang, which uses the built GCC (in /opt/mongodbtoolchain) as its GCC installation.

      v5 clang:

      [ec2-user@ip-10-122-60-47 source-patch-436_toolchain-builder]$ /opt/mongodbtoolchain/revisions/local/stow/llvm-v5.Ywp/bin/clang hello_c.c -v
      MongoDB clang version 19.1.0 (git@github.com:10gen/toolchain-builder.git acdc1709a01126c67dbd4f0f37491e171f64ec29)
      Target: aarch64-mongodb-linux
      Thread model: posix
      InstalledDir: /opt/mongodbtoolchain/revisions/local/stow/llvm-v5.Ywp/bin
      Found candidate GCC installation: /usr/lib/gcc/aarch64-redhat-linux/7
      Selected GCC installation: /usr/lib/gcc/aarch64-redhat-linux/7
      ...
       "/usr/bin/ld" -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -pie -dynamic-linker /lib/ld-linux-aarch64.so.1 ... 

      v4 clang:

      [ec2-user@ip-10-122-58-238 source-patch-421_toolchain-builder]$ /opt/mongodbtoolchain/revisions/local/stow/llvm-v4.lEf/bin/clang -v hello_c.c
      MongoDB clang version 12.0.1 (https://x-access-token:ghs_dToWmFswrAH2WYTmxAu0fkoyODsaUL1lwTPk@github.com/10gen/toolchain-builder.git acdc1709a01126c67dbd4f0f37491e171f64ec29)
      Target: aarch64-mongodb-linux
      Thread model: posix
      InstalledDir: /opt/mongodbtoolchain/revisions/local/stow/llvm-v4.lEf/bin
      Found candidate GCC installation: /opt/mongodbtoolchain/revisions/local/stow/gcc-v4.BQm/lib/gcc/aarch64-mongodb-linux/11.3.0
      Selected GCC installation: /opt/mongodbtoolchain/revisions/local/stow/gcc-v4.BQm/lib/gcc/aarch64-mongodb-linux/11.3.0
      ...
       "/opt/mongodbtoolchain/revisions/local/stow/gcc-v4.BQm/lib/gcc/aarch64-mongodb-linux/11.3.0/../../../../aarch64-mongodb-linux/bin/ld" -EL --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /lib/../lib64/crt1.o ... 

      This is likely related to how the right search dirs for the built clang are not being generated https://jira.mongodb.org/browse/SERVER-98966 .

            Assignee:
            alex.li@mongodb.com Alex Li
            Reporter:
            alex.li@mongodb.com Alex Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: