# stable/12 buildworld failure - Bug related to SVN during libpmc jevent execution



## jimeha (Jul 5, 2021)

Hi folks,

I've been banging my head on buildworld for the past few days using releng/12.1 and stable/12; both just stock 'svn co', no modifications at all, building on a 12.1-RELEASE system, GENERIC kernel.  Both fail during libpmc for 'undeclared identifier's, so I finally had some time to do some digging.  It looks like a bug in the jevents.c logic when '.svn' directories exist (i.e. from a clone).

Example: Fresh "svn co https://svn.freebsd.org/base/stable/12/ ."

NOTE: I have tried without any '-j', same result, read on for example.

NOTE: I edited the shell paths for privacy sake, apologies if one doesn't make sense, the code and obj output both start at STABLE_12/ in the private paths


```
# make -j 16 buildworld
...
    --- all_subdir_lib/libpmc ---
./pmu-events/jevents "x86" /tmp/STABLE_12/lib/libpmc/pmu-events/arch libpmc_events.c
...
    --- all_subdir_lib/libpmc ---
libpmc_events.c:93065:11: error: use of undeclared identifier 'pme_broadwellde'; did you mean 'pme_broadwellde_'?
        .table = pme_broadwellde
                 ^~~~~~~~~~~~~~~
                 pme_broadwellde_
libpmc_events.c:16125:25: note: 'pme_broadwellde_' declared here
static struct pmu_event pme_broadwellde_[] = {
                        ^
libpmc_events.c:93071:11: error: use of undeclared identifier 'pme_broadwell'; did you mean 'pme_broadwell_'?
        .table = pme_broadwell
                 ^~~~~~~~~~~~~
                 pme_broadwell_
libpmc_events.c:10441:25: note: 'pme_broadwell_' declared here
static struct pmu_event pme_broadwell_[] = {
                        ^
libpmc_events.c:93077:11: error: use of undeclared identifier 'pme_broadwell'; did you mean 'pme_broadwell_'?
        .table = pme_broadwell
                 ^~~~~~~~~~~~~
                 pme_broadwell_
...

And several more for broadwellx, bonnell, etc, before it eventually fails out.
```

Checking the generated libpmc_events.c, the 'static' line has the trailing underscore, whereas the 'table' does not:

```
...
    static struct pmu_event pme_broadwellde_[] = {    <<<< EDIT: Here
{
...
    struct pmu_events_map pmu_events_map[] = {
{
        .cpuid = "GenuineIntel-6-56",
        .version = "v5",
        .type = "core",
        .table = pme_broadwellde    <<<< EDIT: vs here
},
...
```

Insert lots of head scratching...

And I resorted to printf comments in jevents.c, ran 'make' to rebuild it, copied it to the obj dir, and re-ran it:


```
In jevents.c

...
static int process_mapfile(FILE *outfp, char *fpath)
{
...
                printf("DEBUG: process_mapfile file_name_to_table_name, fname = %s\n", fname);
                tblname = file_name_to_table_name(fname);
                printf("DEBUG: process_mapfile, tblname = %s\n", tblname);
                fprintf(outfp, "{\n");
...
    static int process_one_file(const char *fpath, const struct stat *sb,
                            int typeflag, struct FTW *ftwbuf)
{
...
                printf("DEBUG: process_one_file file_name_to_table_name, bname = %s\n", bname);
                tblname = file_name_to_table_name(bname);
                printf("DEBUG: process_one_file, tblname = %s\n", tblname);
...
```

Result:


```
[root@myservername /tmp/edit/path/removed/for/privacy/STABLE_12/amd64.amd64/lib/libpmc/pmu-events]# ./jevents "x86" /tmp/STABLE_12/lib/libpmc/pmu-events/arch libpmc_events.c
...
DEBUG: process_one_file file_name_to_table_name, bname = broadwellde/.svn
DEBUG: process_one_file, tblname = pme_broadwellde_    <<<< EDIT: Note the underscore!
...
DEBUG: process_mapfile file_name_to_table_name, fname = broadwellde
DEBUG: process_mapfile, tblname = pme_broadwellde    <<<< EDIT: No underscore here
...
```

So it looks like process_mapfile vs process_one_file call file_name_to_table_name with a slightly different value.

I bet if I delete every '.svn' directory from my local copy, this will build, but that breaks the ability to do any svn update, etc, later of course.

I've also hunted around Google index results for the forums and mailing lists, but can't find anyone else having this problem which is strange if all 12.x branches have had this bug for awhile now.

Thoughts?  Am I just building wrong on the newer version (12+); I've been using buildworld+buildkernel+custom edits for 6+ years now in 6, 8, & 10, no problems there.

Thanks in advance!


----------



## Alexander88207 (Jul 5, 2021)

If the svn stuff is the elephant in the room, do you have already tried to checkout the src using devel/git?

`git clone -o freebsd -b stable/12 https://git.FreeBSD.org/src.git`

Note: Upstream have switched to git, you should consider a switch to it too.


----------



## jimeha (Jul 5, 2021)

Excellent idea, I haven't been on here in awhile and was only aware of the SVN repos, svnweb being heavily relied on when needed for diff's, notes, and such.  A git clone, since only the top-level gets a '.git' directory, would also solve this problem yes.  I'll be sure to use that going forward.

I do wonder if this deserves a bugreport though, because an SVN checkout ("clone") just won't build at all for 12-anything, or if builds via SVN are deprecated, I won't bother?


----------

