!lheuhImcToQZYTQTuI:nixos.org

Nix on macOS

1081 Members
“There are still many issues with the Darwin platform but most of it is quite usable.” — http://yves.gnu-darwin.org164 Servers

Load older messages


SenderMessageTime
4 Jul 2025
@k900:0upti.meK900And Clang is just stricter about this than GCC08:19:47
@megmug:matrix.orgmegmugYeah, we have a header and a corresponding .cxx file that implements it08:20:04
@megmug:matrix.orgmegmugI tried switching it to gcc on MacOS via the CC and CXX env variables but that made things even worse. To my current understanding, because everything else is built with clang and the resulting binaries will not be compatible08:22:10
@k900:0upti.meK900GCC on OSX is not really a good idea AFAIK08:22:57
@k900:0upti.meK900Though I'm far from an OSX expert08:23:02
@k900:0upti.meK900You might want to try building with clang on Linux actually08:23:19
@k900:0upti.meK900Just to see if the issue reproduces08:23:24
@megmug:matrix.orgmegmugthis i should try yes08:24:05
@weethet:catgirl.cloudWeetHet

Imagine that you have

header.h:

#ifndef HEADER_H
#define HEADER_H

template <typename T> class Test {
  T x;

public:
  static Test mkTest(T x);
};

#endif

impl.cpp:

#include "header.h"

template <typename T> Test<T> Test<T>::mkTest(T x) { return Test{x}; }

main.cpp:

#include "header.h"

int main() { Test<int> t = Test<int>::mkTest(3); }
08:24:34
@weethet:catgirl.cloudWeetHetRight?08:24:40
@weethet:catgirl.cloudWeetHet *

Imagine that you have

header.h:

#ifndef HEADER_H
#define HEADER_H

template <typename T> class Test {
  T x;

public:
  static Test mkTest(T x);
};

#endif

impl.cpp:

#include "header.h"

template <typename T> Test<T> Test<T>::mkTest(T x) { return Test{x}; }

main.cpp:

#include "header.h"

int main() { Test<int> t = Test<int>::mkTest(3); }
08:24:47
@weethet:catgirl.cloudWeetHetWell, building it fails08:25:02
@weethet:catgirl.cloudWeetHet
$ g++ main.cpp impl.cpp -o main
Undefined symbols for architecture arm64:
  "Test<int>::mkTest(int)", referenced from:
      _main in main-880b44.o
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
08:25:17
@weethet:catgirl.cloudWeetHetI'm 99% sure you have the same issue08:25:47
@megmug:matrix.orgmegmugOk, but why does it work so flawlessly on x86 linux then?08:26:54
@weethet:catgirl.cloudWeetHetIdk C++ stuff08:27:06
@weethet:catgirl.cloudWeetHetLuck08:27:08
@megmug:matrix.orgmegmug(or, gcc)08:27:13
@megmug:matrix.orgmegmugNVM, you were compiling with gcc08:27:25
@megmug:matrix.orgmegmugNo, you weren't. 08:27:39
@weethet:catgirl.cloudWeetHetIt's macOS "gcc"08:27:43
@weethet:catgirl.cloudWeetHet
$ g++ --version
Apple clang version 17.0.0 (clang-1700.0.13.5)
Target: arm64-apple-darwin24.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
08:28:03
@megmug:matrix.orgmegmugAha08:28:22
@megmug:matrix.orgmegmugYou were spot on. The build fails using clang on Linux x86, too.08:37:38
@k900:0upti.meK900 I assume you'll just have to fix the library then 08:39:41
@megmug:matrix.orgmegmugHm, is it possible to switch the MacOS build to gcc instead? Even if it takes forever to compile everything from scratch?08:41:31
@megmug:matrix.orgmegmugI guess the last time i tried i did it wrong because the macos build failed with a ton of linker errors, but thats understandable since it tried to use precompiled by gcc libraries08:43:17
@weethet:catgirl.cloudWeetHetWhy would you want to build wrong code08:46:34
@weethet:catgirl.cloudWeetHetThat's absolutely not the right way to do things08:46:52
@weethet:catgirl.cloudWeetHetWhat if gcc changes it linking behaviour in the next release08:47:32

Show newer messages


Back to Room ListRoom Version: 6