Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate symbols for architecture x86_64 - MacOS 10.12.4 #28

Closed
Thireus opened this issue Apr 6, 2017 · 3 comments
Closed

Duplicate symbols for architecture x86_64 - MacOS 10.12.4 #28

Thireus opened this issue Apr 6, 2017 · 3 comments
Labels

Comments

@Thireus
Copy link

Thireus commented Apr 6, 2017

Duplicate symbol errors occur when the pcm utilities from the root directory are compiled:

make
c++ -Wall -g -O3 -Wno-unknown-pragmas -I/usr/include -IMacMSRDriver -std=c++0x -c pcm-numa.cpp -o pcm-numa.o
c++ -MM -Wall -g -O3 -Wno-unknown-pragmas -I/usr/include -IMacMSRDriver -std=c++0x pcm-numa.cpp > pcm-numa.d
c++ -Wall -g -O3 -Wno-unknown-pragmas -I/usr/include -IMacMSRDriver -std=c++0x -c msr.cpp -o msr.o

[...]

duplicate symbol std::vector<TopologyEntry, std::allocator<TopologyEntry> >::operator=(std::initializer_list<TopologyEntry>) in:
    pcm-numa.o
    utils.o
duplicate symbol std::vector<TopologyEntry, std::allocator<TopologyEntry> >::assign(std::initializer_list<TopologyEntry>) in:
    pcm-numa.o
    utils.o
duplicate symbol std::vector<TopologyEntry, std::allocator<TopologyEntry> >::insert(__gnu_cxx::__normal_iterator<TopologyEntry const*, std::vector<TopologyEntry, std::allocator<TopologyEntry> > >, std::initializer_list<TopologyEntry>) in:
    pcm-numa.o
    utils.o
ld: 522 duplicate symbols for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [pcm-numa.x] Error 1

For some reason the following lines are defined in cpucounters.h and must be removed in order to compile the utilities without duplicate symbol errors:

#ifndef HACK_TO_REMOVE_DUPLICATE_ERROR
template class PCM_API std::allocator<TopologyEntry>;
template class PCM_API std::vector<TopologyEntry>;
template class PCM_API std::allocator<CounterWidthExtender *>;
template class PCM_API std::vector<CounterWidthExtender *>;
template class PCM_API std::allocator<uint32>;
template class PCM_API std::vector<uint32>;
template class PCM_API std::allocator<char>;
#endif

Alternatively HACK_TO_REMOVE_DUPLICATE_ERROR must be defined somewhere for these lines to be silent during compilation (which is actually something already in place when compiling MacMSRDriver lib and driver).

When the above lines are removed (AFTER compiling the libPcmMsr.dylib from the MacMSRDriver directory) the utilities are compiled successfully.

@opcm
Copy link
Contributor

opcm commented Apr 6, 2017

I am not sure why we don't have this issue on Travis CI OS X build: https://travis-ci.org/opcm/pcm/jobs/217597469

...

@opcm
Copy link
Contributor

opcm commented Apr 7, 2017

HACK_TO_REMOVE_DUPLICATE_ERROR is already defined that should silence the lines:
https://github.com/opcm/pcm/search?utf8=%E2%9C%93&q=HACK_TO_REMOVE_DUPLICATE_ERROR&type=

I can not reproduce it neither with clang nor g++: https://travis-ci.org/opcm/pcm

It seems to be a compiler bug for me. Could you try a different compiler?

@opcm opcm added the invalid label Apr 7, 2017
@opcm
Copy link
Contributor

opcm commented Apr 19, 2017

closing now (seem to be not reproducible)

@opcm opcm closed this as completed Apr 19, 2017
rdementi added a commit that referenced this issue Oct 25, 2021
mjguzik pushed a commit to mjguzik/pcm that referenced this issue Aug 26, 2022
poll2: update rlim.rlim_cur if it's too low
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants