Skip to content

Expand =/$SYSROOT for INPUT/GROUP script commands#950

Open
parth-07 wants to merge 1 commit intoqualcomm:mainfrom
parth-07:SysrootExpansion
Open

Expand =/$SYSROOT for INPUT/GROUP script commands#950
parth-07 wants to merge 1 commit intoqualcomm:mainfrom
parth-07:SysrootExpansion

Conversation

@parth-07
Copy link
Contributor

This commit improves the script parser to expand
the = and $SYSROOT prefix in INPUT/GROUP inputs.

Resolves #927

This commit improves the script parser to expand
the = and $SYSROOT prefix in INPUT/GROUP inputs.

Resolves qualcomm#927

Signed-off-by: Parth Arora <partaror@qti.qualcomm.com>
@parth-07 parth-07 force-pushed the SysrootExpansion branch 3 times, most recently from b5640a0 to c91146e Compare March 18, 2026 09:33
Copy link
Contributor

@quic-seaswara quic-seaswara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cool feature!

InputStrTok =
ThisScriptFile.createFileToken(Name.str(), ThisScriptFile.asNeeded());
ThisScriptFile.createFileToken(ExpandedName, ThisScriptFile.asNeeded());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be done in resolvePath

For example

ld.bfd --sysroot=/tmp/xxx/ =main.o

I could not find this expansion of $SYSROOT for input files, may be I am not using the right version of ld.

if (Name.starts_with("="))
Suffix = Name.substr(1);
else if (Name.starts_with("$SYSROOT"))
Suffix = Name.substr(8); // strlen("$SYSROOT") == 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name.substr(strlen("$SYSROOT")) or create a function to get the suffix.

@@ -0,0 +1 @@
GROUP(=/lib64/lib1.so)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add GROUP($SYSROOT) as well?

RUN: %link %linkopts -o %t.out2 --sysroot=%t.dir -T %p/Inputs/script_sysroot.t %t.main.o --verbose 2>&1 | %filecheck %s --check-prefix=SYSROOT
RUN: %link %linkopts -o %t.out3 --sysroot=%t.dir -T %p/Inputs/group_equals.t %t.main.o --verbose 2>&1 | %filecheck %s --check-prefix=GROUP
RUN: %not %link %linkopts -o %t.out4 -T %p/Inputs/script_equals.t %t.main.o 2>&1 | %filecheck %s --check-prefix=NOSYSROOT
#END_TEST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need verbose output to show how the files are resolved.

Also please annotate map file to show what files are being expanded.

void ScriptParser::addFile(StringRef Name) {
StrToken *InputStrTok = nullptr;
if (Name.consume_front("-l"))
InputStrTok = ThisScriptFile.createNameSpecToken(Name.str(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ld for namespec files ?

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 this pull request may close these issues.

= and $SYSROOT in INPUT|GROUP command does not expand to SYSROOT

2 participants