Skip to content

Clarify documentation for -funique-source-file-names. #135832

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

Merged

Conversation

pcc
Copy link
Contributor

@pcc pcc commented Apr 15, 2025

No description provided.

Created using spr 1.3.6-beta.1
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 15, 2025

@llvm/pr-subscribers-clang

Author: Peter Collingbourne (pcc)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/135832.diff

1 Files Affected:

  • (modified) clang/docs/UsersManual.rst (+23-3)
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index d4656a7e63c99..c75e409dde55e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2301,11 +2301,31 @@ are listed below.
 
    When enabled, allows the compiler to assume that each object file
    passed to the linker has been compiled using a unique source file
-   name. This is useful for reducing link times when doing ThinLTO
+   path. This is useful for reducing link times when doing ThinLTO
    in combination with whole-program devirtualization or CFI.
 
-   A misuse of this flag will generally result in a duplicate symbol
-   error at link time.
+   The full source path passed to the compiler must be unique. This
+   means that, for example, the following is a usage error:
+
+   .. code-block:: console
+
+     $ cd foo
+     $ clang -funique-source-file-names -c foo.c
+     $ cd ../bar
+     $ clang -funique-source-file-names -c foo.c
+     $ cd ..
+     $ clang foo/foo.o bar/foo.o
+    
+   but this is not:
+
+   .. code-block:: console
+
+     $ clang -funique-source-file-names -c foo/foo.c
+     $ clang -funique-source-file-names -c bar/foo.c
+     $ clang foo/foo.o bar/foo.o
+
+   A misuse of this flag will generally either be harmless or result
+   in a duplicate symbol error at link time.
 
 .. option:: -fforce-emit-vtables
 

Copy link
Contributor

@teresajohnson teresajohnson left a comment

Choose a reason for hiding this comment

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

lgtm with one suggestion below

$ clang -funique-source-file-names -c bar/foo.c
$ clang foo/foo.o bar/foo.o

A misuse of this flag will generally either be harmless or result
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to remove the harmless comment as it would be good to discourage uses that violate the intent. So maybe just "may result in a duplicate ..." ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Created using spr 1.3.6-beta.1
Copy link
Contributor Author

@pcc pcc left a comment

Choose a reason for hiding this comment

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

Will leave this for a bit in case @efriedma-quic has any comments

$ clang -funique-source-file-names -c bar/foo.c
$ clang foo/foo.o bar/foo.o

A misuse of this flag will generally either be harmless or result
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@pcc pcc merged commit a1d52fc into main Apr 15, 2025
8 of 10 checks passed
@pcc pcc deleted the users/pcc/spr/clarify-documentation-for-funique-source-file-names branch April 15, 2025 20:04
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 15, 2025
Reviewers: efriedma-quic, teresajohnson

Reviewed By: teresajohnson, efriedma-quic

Pull Request: llvm/llvm-project#135832
var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
Reviewers: efriedma-quic, teresajohnson

Reviewed By: teresajohnson, efriedma-quic

Pull Request: llvm#135832
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants