Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Unreferenced GOs are emitted during the first build. #57

Open
MaggieYingYi opened this issue Oct 22, 2019 · 0 comments
Open

Unreferenced GOs are emitted during the first build. #57

MaggieYingYi opened this issue Oct 22, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@MaggieYingYi
Copy link

MaggieYingYi commented Oct 22, 2019

This is spin-off from issue #55 (“Discarded GOs are emitted during the second build”).

A source file test.cpp:

#include <string>

class opt {
public:
  template <class... Mods> explicit opt(Mods const &... mods) {}
};

class alias {
public:
  template <typename... Mods> explicit alias(Mods const &... mods) {}
};

class desc {
public:
  explicit desc(std::string str);
};

opt hex(desc("Emit number values in hexadecimal notation"));
alias hex2(desc("Alias for --hex"));

Compile 'test.cpp' targeted on repo and dump all compilations:

$ rm clang.db
$ clang --target=x86_64-pc-linux-gnu-repo -fPIC -O3 -fno-exceptions -fno-rtti -c -o repo.o  test.cpp
$ pstore-dump -all-compilations clang.db
---
- file         :
      path : clang.db
      size : 4194304
  compilations :
      - digest      : 09b2f88b14e7c360d47d217df06441e8
        compilation :
            members :
                - digest  : ef8386f25ac3f059174f07dd906cab7c
                  fext    : { addr: 2416, size: 512 }
                  name    : _GLOBAL__sub_I_test.cpp
                  linkage : internal
                - digest  : 484f873a0e2d011e00925c91efa70ead
                  fext    : { addr: 2960, size: 40 }
                  name    : hex
                  linkage : external
                - digest  : a870e5bd6eeed856eb6943c2e087ebb3
                  fext    : { addr: 3040, size: 83 }
                  name    : .str
                  linkage : internal_no_symbol
                - digest  : 5f02559375f7aeeed6950119c54f41f8
                  fext    : { addr: 3168, size: 40 }
                  name    : hex2
                  linkage : external
                - digest  : 329827f4929e81281275433baabfd270
                  fext    : { addr: 2216, size: 56 }
                  name    : .str.2
                  linkage : internal_no_symbol
                - digest  : 85b4d814cd82b06dd79a000a1bf11673
                  fext    : { addr: 2304, size: 80 }
                  name    : llvm.global_ctors
                  linkage : append
            path    : /home/maggie/repo_work/repo-bug/NewIssue
            triple  : x86_64-pc-linux-gnu-repo
...

We could see that the private symbol .str.2is in the compilation file.

If you dump all fragments using the following command, you will find the .str.2is not referenced by any functions/variables. Therefore, the .str.2should not be emitted into the compilation file.

$ pstore-dump -all-fragments clang.db
@paulhuggett paulhuggett changed the title Unreferenced GOs are emitted into the repo object file during the first time build. Unreferenced GOs are emitted into the repo object file during the first build. Oct 23, 2019
@paulhuggett paulhuggett changed the title Unreferenced GOs are emitted into the repo object file during the first build. Unreferenced GOs are emitted during the first build. Oct 24, 2019
@paulhuggett paulhuggett added the bug Something isn't working label Feb 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants