Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Libraries/pbxspec/Sources/PBX/FileType.cpp:51:46: error: assigning field to itself [-Werror,-Wself-assign-field] #307

Open
saper opened this issue Oct 16, 2019 · 10 comments

Comments

@saper
Copy link

saper commented Oct 16, 2019

Building with clang:

> gmake
mkdir -p build
cmake -Bbuild -H. -G Ninja -DCMAKE_INSTALL_PREFIX=
-- Configuring done
-- Generating done
-- Build files have been written to: /home/saper/sw/xcbuild/build
ninja -C build
ninja: Entering directory `build'
[32/199] Building CXX object Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/FileType.cpp.o
FAILED: Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/FileType.cpp.o
/usr/bin/c++  -Dpbxspec_EXPORTS -I../Libraries/pbxspec/Headers -I../Libraries/pbxspec/PrivateHeaders -I../Libraries/pbxsetting/Headers -I../Libraries/process/Headers -I../Libraries/ext/Headers -I../Libraries/libutil/Headers -I../Libraries/plist/Headers -std=c++11 -fno-rtti -fno-exceptions -fPIC   -Wall -Werror -fcolor-diagnostics -Wno-delete-non-virtual-dtor -MD -MT Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/FileType.cpp.o -MF Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/FileType.cpp.o.d -o Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/FileType.cpp.o -c ../Libraries/pbxspec/Sources/PBX/FileType.cpp
../Libraries/pbxspec/Sources/PBX/FileType.cpp:51:46: error: assigning field to itself [-Werror,-Wself-assign-field]
    _extensions                              = _extensions; /* Explicitly not inherited. */
                                             ^
1 error generated.
[34/199] Building CXX object Libraries/pbxspec/CMakeFiles/pbxspec.dir/Sources/PBX/Compiler.cpp.o
> cc --version
FreeBSD clang version 7.0.1 (tags/RELEASE_701/final 349250) (based on LLVM 7.0.1)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
saper added a commit to saper/xcbuild that referenced this issue Oct 16, 2019
saper added a commit to saper/xcbuild that referenced this issue Oct 21, 2019
saper added a commit to saper/xcbuild that referenced this issue Oct 21, 2019
@compdzwio
Copy link

port freebsd link:https://github.com/czom/xcbuild-port-BSD

@saper
Copy link
Author

saper commented Nov 9, 2019

nice, I have a working port too, but will not sign the CLA with Facebook. https://github.com/saper/xcbuild (see the branches)

@sas
Copy link
Contributor

sas commented Nov 15, 2019

This is pretty cool work guys. Just curious though, can you share what you are using xcbuild on FreeBSD for?

@saper
Copy link
Author

saper commented Nov 16, 2019

I'd like to have (Pure)Darwin bootstrapped on FreeBSD without MacOS

@NaruFGT
Copy link

NaruFGT commented Jan 7, 2020

I would be interested in why this was originally implemented to "disinherit" _extensions, @saper did you find the design reason? I understand the code will compile but I was hoping for a comment about why the disinheritance can be discarded.

@saper
Copy link
Author

saper commented Jan 7, 2020

@NaruFGT I am not sure I have done anything with it. And I am not even sure I understand what you mean... can you elaborate a bit?

@NaruFGT
Copy link

NaruFGT commented Jan 7, 2020

@saper in your freebsd-fixes branch, you modify pbxspec/Sources/PBX/FileType.cpp removing _extensions = _extensions; /* Explicitly not inherited. */
You referenced this issue in your commit.
I'm hoping you discovered that the disinheritance was not necessary but there isn't much text in your commit about how or why this fixes the issue.
If the goal is just to suppress the error, you can modify CMakeLists.txt with -Wno-error=self-assign-field however if you have an understanding of pbxspec and have discovered the disinheritance is unnecessary, I would hope for more details.

@saper
Copy link
Author

saper commented Jan 7, 2020

Ah, thank you. I see no way to test it (any way to have something like dump_xcspec that outputs actual computed values?), but I do not see any way the _extensions could be "inherited" from another filetype if there is no explicit inheritance in the inherit method.

From what I understand we do not do any C++ inheritance here (C++ base class Specification has no _extensions field), but we do runtime inheritance based on the baseOn attribute in the xcspec file.

As I understand this is the runtime inheritance chain for the file with extension .c:

file.xcspec text.xcspec sourcecode.xcspec sourcecode.c.xcspec sourcecode.c.c.xcspec

text.xcspec gives

Extensions = (
    txt,
    "",
);

But sourcecode.xcspec and sourcecode.c.xcspec do not list any extensions at all. Therefore they should have no extensions and do not inherit anything.

sourcecode.c.c.xcspec on the other hand defines

 Extensions = (
    "c",
);

so .c should be the only file extension assigned to this type.

I do not see any way how extensions should magically get inherited, I think this line was just developer's shorthand to indicate that this field has not been forgotten and has been explicitly left out.

But this is the first time I am dealing with this so I could be all wrong. I don't know how to dump actual file type definitions though - please help if you can!

@NaruFGT
Copy link

NaruFGT commented Jan 8, 2020

I like the idea of providing a command to dump the computed values. It looks like we have absolutely no Tests for pbxspec/ and Tests in pbxbuild/ don't appear relevant either. I believe enumerating the calculated values would provide important diagnostic information.
It seems like a bigger modification than I'm comfortable with doing at the moment because I don't seem to have a sane build of this project in the first place ( #306).

@saper
Copy link
Author

saper commented Jan 9, 2020

I got confirmation via the private channel that my assumption was correct - the assignment was just an indication of intent.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants