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

probe2trace.pl: arch embedded eq mismatch #455

Open
maxsharabayko opened this issue May 25, 2021 · 2 comments · May be fixed by #466
Open

probe2trace.pl: arch embedded eq mismatch #455

maxsharabayko opened this issue May 25, 2021 · 2 comments · May be fixed by #466

Comments

@maxsharabayko
Copy link
Contributor

When building quicly in Ubintu under Windows Subsystem for Linux there is an error in the generated embedded-probes.h file. There is no matching #endif in the end.

probe2trace.pl:

my $arch = $^O; # here 'linux'

GetOptions("arch=s" => \$arch) # here embedded
    or die "invalid command option\n";

After GetOptions(..) arch contains embedded with some extra character in the end. Probably /n. Therefore the following condition returns false:

if ($arch eq 'embedded\r') {
print << 'EOT';

#endif
EOT
}

The best I could do to trace the issue without known perl:

print "Arch in the end: $arch\n";

if ($arch eq 'embedded') {
print << 'EOT';

#endif
EOT
}
else {
print "Arch does not match embedded: $arch...";
}

results in:

Arch in the end: embedded
Arch does not match embedded: embedded
...
@maxsharabayko
Copy link
Contributor Author

Temporal workaround:

if ($arch eq 'linux') {
} elsif ($arch eq 'darwin') {
} else {
print << 'EOT';

#endif
EOT
}

@maxsharabayko
Copy link
Contributor Author

Update

After a discussion with @kazuho, confirmed that there is the CR character in the end.

perl

print "Arch: $arch\n";
print 'arch val:', unpack('H*', $arch), "\n";
GetOptions("arch=s" => \$arch)
    or die "invalid command option\n";
print "Arch: $arch\n";
print 'arch val after:', unpack('H*', $arch), "\n";

Result

Arch: linux
arch val:6c696e7578
Arch: embedded
arch val after:656d6265646465640d

Reason

Looks related to dos and unix line endings. When I clone the repo from WSL, it seems to work (no CR in the end).
But if I clone the repo from Windows, and then cmake and build it from WSL, this extra CR appears.

Workaround no.2

Add the following right after or die ....:

$arch =~ s/\r$//; # remove excess \r on WSL

maxsharabayko added a commit to maxsharabayko/quicly that referenced this issue Jun 17, 2021
maxsharabayko added a commit to maxsharabayko/quicly that referenced this issue Jun 17, 2021
@maxsharabayko maxsharabayko linked a pull request Jun 17, 2021 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant