Skip to content

Commit 8ebfa96

Browse files
committed
treewide: Format all Nix files
Format all Nix files using the officially approved formatter, making the CI check introduced in the previous commit succeed: nix-build ci -A fmt.check This is the next step of the of the [implementation](NixOS/nixfmt#153) of the accepted [RFC 166](NixOS/rfcs#166). This commit will lead to merge conflicts for a number of PRs, up to an estimated ~1100 (~33%) among the PRs with activity in the past 2 months, but that should be lower than what it would be without the previous [partial treewide format](NixOS/nixpkgs#322537). Merge conflicts caused by this commit can now automatically be resolved while rebasing using the [auto-rebase script](https://github.com/NixOS/nixpkgs/tree/8616af08d915377bd930395f3b700a0e93d08728/maintainers/scripts/auto-rebase). If you run into any problems regarding any of this, please reach out to the [formatting team](https://nixos.org/community/teams/formatting/) by pinging @NixOS/nix-formatting.
1 parent d66d9bc commit 8ebfa96

File tree

3 files changed

+694
-540
lines changed

3 files changed

+694
-540
lines changed

pkgs/development/compilers/gcc/common/builder.nix

Lines changed: 91 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
let
99
forceLibgccToBuildCrtStuff = import ./libgcc-buildstuff.nix { inherit lib stdenv; };
10-
isCross = ! lib.systems.equals stdenv.targetPlatform stdenv.hostPlatform;
10+
isCross = !lib.systems.equals stdenv.targetPlatform stdenv.hostPlatform;
1111
in
1212

1313
# We don't support multilib and cross at the same time
@@ -266,99 +266,100 @@ originalAttrs:
266266
makeCompatibilitySymlink lib $targetConfig/lib64
267267
'';
268268

269-
postInstall = ''
270-
# Clean up our compatibility symlinks (see above)
271-
for link in "''${compatibilitySymlinks[@]}"; do
272-
echo "Removing compatibility symlink: $link"
273-
rm -f "$link"
274-
done
275-
276-
# Move target runtime libraries to lib output.
277-
# For non-cross, they're in $out/lib; for cross, they're in $out/$targetConfig/lib.
278-
targetLibDir="''${targetConfig+$targetConfig/}lib"
279-
280-
moveToOutput "$targetLibDir/lib*.so*" "''${!outputLib}"
281-
moveToOutput "$targetLibDir/lib*.dylib" "''${!outputLib}"
282-
moveToOutput "$targetLibDir/lib*.dll.a" "''${!outputLib}"
283-
moveToOutput "$targetLibDir/lib*.dll" "''${!outputLib}"
284-
moveToOutput "share/gcc-*/python" "''${!outputLib}"
285-
286-
if [ -z "$enableShared" ]; then
287-
moveToOutput "$targetLibDir/lib*.a" "''${!outputLib}"
288-
fi
289-
290-
for i in "''${!outputLib}"/$targetLibDir/*.py; do
291-
substituteInPlace "$i" --replace "$out" "''${!outputLib}"
292-
done
293-
294-
# Multilib and cross can't exist at the same time, so just use lib64 here
295-
if [ -n "$enableMultilib" ]; then
296-
moveToOutput "lib64/lib*.so*" "''${!outputLib}"
297-
moveToOutput "lib64/lib*.dylib" "''${!outputLib}"
298-
moveToOutput "lib64/lib*.dll.a" "''${!outputLib}"
299-
moveToOutput "lib64/lib*.dll" "''${!outputLib}"
300-
301-
for i in "''${!outputLib}"/lib64/*.py; do
302-
substituteInPlace "$i" --replace "$out" "''${!outputLib}"
303-
done
304-
fi
269+
postInstall =
270+
''
271+
# Clean up our compatibility symlinks (see above)
272+
for link in "''${compatibilitySymlinks[@]}"; do
273+
echo "Removing compatibility symlink: $link"
274+
rm -f "$link"
275+
done
276+
277+
# Move target runtime libraries to lib output.
278+
# For non-cross, they're in $out/lib; for cross, they're in $out/$targetConfig/lib.
279+
targetLibDir="''${targetConfig+$targetConfig/}lib"
280+
281+
moveToOutput "$targetLibDir/lib*.so*" "''${!outputLib}"
282+
moveToOutput "$targetLibDir/lib*.dylib" "''${!outputLib}"
283+
moveToOutput "$targetLibDir/lib*.dll.a" "''${!outputLib}"
284+
moveToOutput "$targetLibDir/lib*.dll" "''${!outputLib}"
285+
moveToOutput "share/gcc-*/python" "''${!outputLib}"
286+
287+
if [ -z "$enableShared" ]; then
288+
moveToOutput "$targetLibDir/lib*.a" "''${!outputLib}"
289+
fi
305290
306-
# Remove `fixincl' to prevent a retained dependency on the
307-
# previous gcc.
308-
rm -rf $out/libexec/gcc/*/*/install-tools
309-
rm -rf $out/lib/gcc/*/*/install-tools
310-
311-
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
312-
rm -rf $out/bin/gccbug
313-
314-
# Remove .la files, they're not adjusted for the makeCompatibilitySymlink magic,
315-
# which confuses libtool and leads to weird linking errors.
316-
# Removing the files just makes libtool link .so files directly, which is usually
317-
# what we want anyway.
318-
find $out -name '*.la' -delete
319-
320-
if type "install_name_tool"; then
321-
for i in "''${!outputLib}"/lib/*.*.dylib "''${!outputLib}"/lib/*.so.[0-9]; do
322-
install_name_tool -id "$i" "$i" || true
323-
for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do
324-
new_path=`echo "$old_path" | sed "s,$out,''${!outputLib},"`
325-
install_name_tool -change "$old_path" "$new_path" "$i" || true
326-
done
327-
done
328-
fi
291+
for i in "''${!outputLib}"/$targetLibDir/*.py; do
292+
substituteInPlace "$i" --replace "$out" "''${!outputLib}"
293+
done
329294
330-
# Get rid of some "fixed" header files
331-
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux,sys/mount.h,bits/statx.h,pthread.h}
295+
# Multilib and cross can't exist at the same time, so just use lib64 here
296+
if [ -n "$enableMultilib" ]; then
297+
moveToOutput "lib64/lib*.so*" "''${!outputLib}"
298+
moveToOutput "lib64/lib*.dylib" "''${!outputLib}"
299+
moveToOutput "lib64/lib*.dll.a" "''${!outputLib}"
300+
moveToOutput "lib64/lib*.dll" "''${!outputLib}"
332301
333-
# Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
334-
for i in $out/bin/*-gcc*; do
335-
if cmp -s $out/bin/gcc $i; then
336-
ln -sfn gcc $i
337-
fi
338-
done
302+
for i in "''${!outputLib}"/lib64/*.py; do
303+
substituteInPlace "$i" --replace "$out" "''${!outputLib}"
304+
done
305+
fi
339306
340-
for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
341-
if cmp -s $out/bin/g++ $i; then
342-
ln -sfn g++ $i
343-
fi
344-
done
307+
# Remove `fixincl' to prevent a retained dependency on the
308+
# previous gcc.
309+
rm -rf $out/libexec/gcc/*/*/install-tools
310+
rm -rf $out/lib/gcc/*/*/install-tools
311+
312+
# More dependencies with the previous gcc or some libs (gccbug stores the build command line)
313+
rm -rf $out/bin/gccbug
314+
315+
# Remove .la files, they're not adjusted for the makeCompatibilitySymlink magic,
316+
# which confuses libtool and leads to weird linking errors.
317+
# Removing the files just makes libtool link .so files directly, which is usually
318+
# what we want anyway.
319+
find $out -name '*.la' -delete
320+
321+
if type "install_name_tool"; then
322+
for i in "''${!outputLib}"/lib/*.*.dylib "''${!outputLib}"/lib/*.so.[0-9]; do
323+
install_name_tool -id "$i" "$i" || true
324+
for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do
325+
new_path=`echo "$old_path" | sed "s,$out,''${!outputLib},"`
326+
install_name_tool -change "$old_path" "$new_path" "$i" || true
327+
done
328+
done
329+
fi
345330
346-
# Two identical man pages are shipped (moving and compressing is done later)
347-
for i in "$out"/share/man/man1/*g++.1; do
348-
if test -e "$i"; then
349-
man_prefix=`echo "$i" | sed "s,.*/\(.*\)g++.1,\1,"`
350-
ln -sf "$man_prefix"gcc.1 "$i"
351-
fi
352-
done
353-
''
354-
# if cross-compiling, link from $lib/lib to $lib/${targetConfig}.
355-
# since native-compiles have $lib/lib as a directory (not a
356-
# symlink), this ensures that in every case we can assume that
357-
# $lib/lib contains the .so files
358-
+ lib.optionalString isCross ''
359-
if [ -e "$lib/$targetConfig/lib" ]; then
360-
ln -s "$lib/$targetConfig/lib" "$lib/lib"
361-
fi
362-
'';
331+
# Get rid of some "fixed" header files
332+
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux,sys/mount.h,bits/statx.h,pthread.h}
333+
334+
# Replace hard links for i686-pc-linux-gnu-gcc etc. with symlinks.
335+
for i in $out/bin/*-gcc*; do
336+
if cmp -s $out/bin/gcc $i; then
337+
ln -sfn gcc $i
338+
fi
339+
done
340+
341+
for i in $out/bin/c++ $out/bin/*-c++* $out/bin/*-g++*; do
342+
if cmp -s $out/bin/g++ $i; then
343+
ln -sfn g++ $i
344+
fi
345+
done
346+
347+
# Two identical man pages are shipped (moving and compressing is done later)
348+
for i in "$out"/share/man/man1/*g++.1; do
349+
if test -e "$i"; then
350+
man_prefix=`echo "$i" | sed "s,.*/\(.*\)g++.1,\1,"`
351+
ln -sf "$man_prefix"gcc.1 "$i"
352+
fi
353+
done
354+
''
355+
# if cross-compiling, link from $lib/lib to $lib/${targetConfig}.
356+
# since native-compiles have $lib/lib as a directory (not a
357+
# symlink), this ensures that in every case we can assume that
358+
# $lib/lib contains the .so files
359+
+ lib.optionalString isCross ''
360+
if [ -e "$lib/$targetConfig/lib" ]; then
361+
ln -s "$lib/$targetConfig/lib" "$lib/lib"
362+
fi
363+
'';
363364
}
364365
))

0 commit comments

Comments
 (0)