[PATCH] D45508: Implement --ctors-in-init-array.

Harmen Stoppels via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 01:05:03 PDT 2022


haampie added a comment.

@MaskRay, not sure if I follow

> This is not so accurate.

When using lld (and glibc 2.31), constructors in object files compiled with default cross GCC < 12 configuration are not run:

  $ cat foo.cc 
  #include <iostream>
  class Foo {
  public:
      Foo() { std::cout << "foo\n"; }
  };
  Foo foo;
  
  $ cat main.cc 
  #include <iostream>
  int main() {
      std::cout << "hello\n";
  }
  
  $ gcc --version
  x86_64-linux-gnu-gcc (GCC) 8.1.0
  
  $ gcc -c foo.cc
  $ clang++ main.cc foo.o 
  $ ./a.out 
  foo
  hello
  
  $ clang++ -fuse-ld=lld main.cc foo.o 
  $ ./a.out 
  hello

Is that expected or not?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45508/new/

https://reviews.llvm.org/D45508



More information about the llvm-commits mailing list