Hi all!
I am not a regular user of clang as I mainly use Rust these days but I came across a weird issue while using snmalloc.
It seems that static inline
data members are lowered in a weird way on Mac OS X, on both ARM64 and x86_64. Even this simple test produces huge binaries:
container.h
#pragma once
#include <cstdint>
class Container {
public:
inline static uint8_t inner[256000000];
};
main.cc
#include "container.h"
int main() {
return Container::inner[0];
}
ARM64/x86_64 does not matter:
$ ~/clang+llvm-12.0.0-x86_64-apple-darwin/bin/clang -O3 -std=c++17 main.cc --target=x86_64-apple-darwin -c; ls -l main.o
-rw-r--r-- 1 hans staff 256000744 Jun 21 16:29 main.o
It is the same with open-source clang as with Apple clang.
$ ~/clang+llvm-12.0.0-x86_64-apple-darwin/bin/clang --version
clang version 12.0.0
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Users/hans/clang+llvm-12.0.0-x86_64-apple-darwin/bin
On Linux the data is stored properly in the .bss section.
Is this a bug or expected behavior?