conda-forge / conda-forge/linux-sysroot-feedstock

Undefined reference to `__libc_single_threaded`

Open
#61 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
5
Forks
18
PR merge metrics
No merged PRs in 30d

Description

### Comment:

Preface: I think this question is suited for this feedstock but feel free to re-direct me to another resource/area that is better suited.

Hi All,

I'm building a program that uses `pthreads` with a host that has GLIBC version of `2.37` but I'm encountering errors when building. Specifically I'm seeing an error that `__libc_single_threaded` is undefined.

Here is the program I'm compiling (simplified to just point to the `__libc_single_threaded` variable that is missing):

File: `a.c`
```
extern char __libc_single_threaded;

int main(void) {
return __libc_single_threaded;
}
```

Conda environment file: `temp-env.yaml`
```
channels:
- conda-forge
- nodefaults
dependencies:
- gcc
- gxx
- sysroot_linux-64
- conda-gcc-specs
- binutils
```

Cmdline (creates failure)
```
g++ a.c -o out
```

Error seen
```
<>/temp-env/bin/../lib/gcc/x86_64-conda-linux-gnu/13.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/ccGSVWOR.o: warning: relocation against `__libc_single_threaded' in read-only section `.text'
<>/temp-env/bin/../lib/gcc/x86_64-conda-linux-gnu/13.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: /tmp/ccGSVWOR.o: in function `main':
a.c:(.text+0x7): undefined reference to `__libc_single_threaded'
<>/temp-env/bin/../lib/gcc/x86_64-conda-linux-gnu/13.2.0/../../../../x86_64-conda-linux-gnu/bin/ld: warning: creating DT_TEXTREL in a PIE
collect2: error: ld returned 1 exit status
```

Running a similar compile with the host compiler works. From my understanding this is because the isolated conda environment `libc` doesn't have the `__libc_single_threaded` variable defined while the host `libc` does? Is this an issue with the sysroot/environment that conda bundles together or do I need to somehow link against the `libc` of the host to get the variable?

Thanks in advance for any help or guidance!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.